Ready for release? 🤞

This commit is contained in:
oitsjustjose 2020-07-05 16:43:12 -05:00
commit 80930dac4f
11 changed files with 410 additions and 32 deletions

View file

@ -19,10 +19,10 @@ export const init = (app: Application, passport: PassportStatic) => {
await conf.save()
if (req.isAuthenticated() && req.user) {
req.user.configs.push({
name: req.body.name,
conf: conf.shortid
})
req.user.configs.push(
conf.shortid
)
await req.user.save()
}
res.status(200).send(conf)
} catch (ex) {
@ -32,6 +32,24 @@ export const init = (app: Application, passport: PassportStatic) => {
}
})
app.get('/configs', async (req, res) => {
if (req.isAuthenticated() && req.user) {
res.render('configs', {
user: req.user
})
} else {
res.redirect('/login?origin=/configs')
}
})
app.post('/configs', async (req, res) => {
if (req.isAuthenticated() && req.user) {
res.json(req.user.configs)
} else {
res.json([])
}
})
app.get('/configs/:id', async (req, res) => {
const conf = await ConfigDB.findOne({
shortid: req.params.id