Init -- well, everything.
This commit is contained in:
parent
0b2fa17341
commit
4645561d33
9 changed files with 352 additions and 0 deletions
28
src/app/routes/routes.ts
Normal file
28
src/app/routes/routes.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { Application } from "express"
|
||||
import { PassportStatic } from "passport"
|
||||
import * as Auth from './auth'
|
||||
|
||||
export const init = (app: Application, passport: PassportStatic) => {
|
||||
app.get('/', async (req, res) => {
|
||||
if (req.isAuthenticated() && req.user) {
|
||||
res.render('home')
|
||||
} else {
|
||||
res.redirect('/login?origin=/')
|
||||
}
|
||||
})
|
||||
|
||||
app.put('/', async (req, res) => {
|
||||
if (req.isAuthenticated() && req.user) {
|
||||
req.user.configs.push({
|
||||
name: req.body.name,
|
||||
conf: req.body.config
|
||||
})
|
||||
} else {
|
||||
res.status(401).send({
|
||||
error: 'Not logged in!'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Auth.init(app, passport)
|
||||
}
|
||||
Loading…
Reference in a new issue