better list with no more funny hidden leaks
This commit is contained in:
parent
24c127178b
commit
721497d02e
1 changed files with 11 additions and 4 deletions
13
src/index.ts
13
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));
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue