Ready for release? 🤞
This commit is contained in:
parent
a8b9d9ff32
commit
80930dac4f
11 changed files with 410 additions and 32 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue