diff --git a/package-lock.json b/package-lock.json index bbed7f8..31b81dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -114,75 +114,18 @@ "fastq": "^1.6.0" } }, - "@types/bson": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/bson/-/bson-4.0.2.tgz", - "integrity": "sha512-+uWmsejEHfmSjyyM/LkrP0orfE2m5Mx9Xel4tXNeqi1ldK5XMQcDsFkBmLDtuyKUbxj2jGDo0H240fbCRJZo7Q==", - "requires": { - "@types/node": "*" - } - }, "@types/color-name": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", "dev": true }, - "@types/express": { - "version": "github:types/express#7670cf1cbce96b3159e3ff04a253926b34111220", - "from": "github:types/express", - "requires": { - "@types/serve-static": "github:types/npm-serve-static#c1f96843c8b96a37f6c534cb1dadb48f5329e4e0", - "path-to-regexp": "github:pillarjs/path-to-regexp#ec285ed3500aed455df59e3b8b07f473412918a4" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "path-to-regexp": { - "version": "github:pillarjs/path-to-regexp#ec285ed3500aed455df59e3b8b07f473412918a4", - "from": "github:pillarjs/path-to-regexp#ec285ed3500aed455df59e3b8b07f473412918a4", - "requires": { - "isarray": "0.0.1" - } - } - } - }, "@types/json-schema": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz", "integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==", "dev": true }, - "@types/mongodb": { - "version": "3.5.26", - "resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.5.26.tgz", - "integrity": "sha512-p0X2VJgIBNHfNBdZdzzG8eQ/3bf6mQoXDT0UhVyVEdSzXEa1+2pFcwGvEZp72sjztyBwfRKlgrXMjCVavLcuGg==", - "requires": { - "@types/bson": "*", - "@types/node": "*" - } - }, - "@types/mongoose": { - "version": "5.7.36", - "resolved": "https://registry.npmjs.org/@types/mongoose/-/mongoose-5.7.36.tgz", - "integrity": "sha512-ggFXgvkHgCNlT35B9d/heDYfSqOSwTmQjkRoR32sObGV5Xjd0N0WWuYlLzqeCg94j4hYN/OZxZ1VNNLltX/IVQ==", - "requires": { - "@types/mongodb": "*", - "@types/node": "*" - } - }, - "@types/node": { - "version": "14.6.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.2.tgz", - "integrity": "sha512-onlIwbaeqvZyniGPfdw/TEhKIh79pz66L1q06WUQqJLnAb6wbjvOtepLYTGHTqzdXgBYIE3ZdmqHDGsRsbBz7A==" - }, - "@types/serve-static": { - "version": "github:types/npm-serve-static#c1f96843c8b96a37f6c534cb1dadb48f5329e4e0", - "from": "github:types/npm-serve-static#c1f96843c8b96a37f6c534cb1dadb48f5329e4e0" - }, "@typescript-eslint/eslint-plugin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.0.1.tgz", diff --git a/package.json b/package.json index 804b78b..9dbe388 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,6 @@ "author": "oatmealine", "license": "MIT", "dependencies": { - "@types/express": "github:types/express", - "@types/mongoose": "^5.7.36", "express": "^4.17.1", "mongoose": "^5.10.2", "mongoose-int32": "^0.4.1", diff --git a/src/html/upload.html b/src/html/upload.html deleted file mode 100644 index 8670e9e..0000000 --- a/src/html/upload.html +++ /dev/null @@ -1,16 +0,0 @@ - - - file upload - - -
-
-
-
-
-
-
- -
- - \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 0596a04..ec12a8c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,48 +37,38 @@ const logger = winston.createLogger({ ] }); -function returnStatic(page) { - return (req, res) => { - fs.readFile(`src/html/${page}`, 'utf8', (err, data) => { - if (err) throw err; - res.send(data); - }); - }; -} - logger.info('connecting to mongodb database'); db.then(() => { logger.info('connected to database!'); const app = express(); - // @ts-ignore - app.use(express.urlencoded({extended: true})); + app.use(express.urlencoded({ extended: true })); app.set('db', db); app.set('config', config); app.set('logger', logger); - app.get('/upload', returnStatic('upload.html')); - - app.post('/upload', async (req, res) => { // only for testing, very abusable - const file = new File(req.body); + app.get('/upload', async (req, res) => { // only for testing, very abusable + const file = new File({ + title: 'penis', // look how mature i am + artist: 'cock' + }); await file.save(); - res.send('uploaded file'); + res.send('made and saved a sample file'); }); app.get('/list', async (req, res) => { // only for testing - const docs = await File.find({}); - const map = docs.map(d => { + let docs = await File.find({}); + docs = docs.map(d => { const keys = Object.keys(d.toObject()).filter(k => !k.startsWith('_')); const obj = {}; for (const key of keys) obj[key] = d[key]; return obj; }); - - res.send(JSON.stringify(map)); + res.send(JSON.stringify(docs)); }); app.get('/', (req, res) => { diff --git a/src/schema.ts b/src/schema.ts index d49d34d..b4c8bd8 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -16,11 +16,8 @@ const Chart = new Schema({ const FileSchema = new Schema({ title: {type: String, default: 'unknown'}, - titleTranslit: String, artist: {type: String, default: 'unknown'}, - artistTranslit: String, subtitle: String, - subtitleTranslit: String, credit: String, uploader: {type: String, default: '00000000-0000-4000-a000-000000000000'}, sample: Sample,