better list with no more funny hidden leaks

This commit is contained in:
oat 2020-09-02 17:24:49 +03:00
parent 24c127178b
commit 721497d02e
Signed by: oat
GPG key ID: DD83A9617A252385

View file

@ -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));
});