diff --git a/.env.example b/.env.example deleted file mode 100644 index 1446139..0000000 --- a/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -DISCORD_OAUTH_CLIENTID="" -DISCORD_OAUTH_CLIENTSECRET="" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4acb044..590ec1c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ node_modules built config/config.json -*.log -.env \ No newline at end of file +*.log \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e9cd86e..9ec1de8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -422,14 +422,6 @@ "resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz", "integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==" }, - "axios": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz", - "integrity": "sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==", - "requires": { - "follow-redirects": "^1.10.0" - } - }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -707,11 +699,6 @@ "esutils": "^2.0.2" } }, - "dotenv": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", - "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" - }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -1064,11 +1051,6 @@ "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==" }, - "follow-redirects": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz", - "integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==" - }, "forwarded": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", diff --git a/package.json b/package.json index cbac83e..b3188f9 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,6 @@ "dependencies": { "@types/express": "github:types/express", "@types/mongoose": "^5.7.36", - "axios": "^0.20.0", - "dotenv": "^8.2.0", "express": "^4.17.1", "express-fileupload": "^1.2.0", "mongoose": "^5.10.2", diff --git a/src/auth.ts b/src/auth.ts deleted file mode 100644 index 5b730f2..0000000 --- a/src/auth.ts +++ /dev/null @@ -1,40 +0,0 @@ -const API_ENDPOINT = 'https://discord.com/api/v6'; - -const axios = require('axios').default; - -export function run(app) { - app.get('/discordauth', async (req, res) => { - const code = req.query.code; - - if (code) { - try { - const data = new URLSearchParams({ - client_id: process.env.DISCORD_OAUTH_CLIENTID, - client_secret: process.env.DISCORD_OAUTH_CLIENTSECRET, - grant_type: 'authorization_code', - code: code, - redirect_uri: 'http://localhost:8080/discordauth', - scope: 'identify' - }); - - const postRes = await axios.post(`${API_ENDPOINT}/oauth2/token`, data, { - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - } - }); - - const userInfo = await axios.get(`${API_ENDPOINT}/users/@me`, { - headers: { - authorization: `${postRes.data.token_type} ${postRes.data.access_token}` - } - }); - - res.send(`hi ${userInfo.data.username}#${userInfo.data.discriminator}`); - } catch(err) { - res.send(`whoooops
${err}`); - } - } else { - res.send('https://discord.com/api/oauth2/authorize?client_id=750952563079250012&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fdiscordauth&response_type=code&scope=identify'); - } - }); -} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index f3a01a0..cc1f8e9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,10 +8,6 @@ import * as format from './lib/format'; import { File } from './schema'; import * as upload from './upload'; -import * as auth from './auth'; - -// .env stuff -require('dotenv').config(); const config = JSON.parse(fs.readFileSync('./config/config.json', {encoding: 'utf8'})); @@ -59,7 +55,6 @@ db.then(() => { app.set('logger', logger); upload.run(app); - auth.run(app); app.get('/list', async (req, res) => { // only for testing const docs = await File.find({}); diff --git a/src/schema.ts b/src/schema.ts index b7ea0d6..2bf463c 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -29,11 +29,4 @@ const FileSchema = new Schema({ charts: [Chart] }); -export const File = mongoose.model('File', FileSchema); - -const UserSchema = new Schema({ // this is pretty much just a discord user lol - id: String, // cus longass number - approved: Boolean -}); - -export const User = mongoose.model('User', UserSchema); \ No newline at end of file +export const File = mongoose.model('File', FileSchema); \ No newline at end of file