diff --git a/src/index.ts b/src/index.ts index 660b9ee..ec12a8c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -49,18 +49,25 @@ db.then(() => { app.set('config', config); app.set('logger', logger); - app.get('/upload', (req, res) => { // only for testing, very abusable + app.get('/upload', async (req, res) => { // only for testing, very abusable const file = new File({ title: 'penis', // look how mature i am artist: 'cock' }); - file.save(); + await file.save(); res.send('made and saved a sample file'); }); app.get('/list', async (req, res) => { // only for testing - const docs = await File.find({}); + 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(docs)); }); @@ -68,7 +75,7 @@ db.then(() => { res.send('wip'); }); - + app.get('*', (req, res) => { res.status(404).send('404'); });