mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 08:32:37 +08:00
745c579b82
- Added new WEBPACK env var which is enabled during yarn build scripts - Defered redis starting until listen is called - Moved pubsub to a factory pattern init - Async/Await'ed the routes - Moved pubsub handle for routes into middleware - Adjusted redis cache and job processors to have lazy connection starting - Disabled mongo from auto-connecting on require - Adjusted package redis clients to act as factory singletons instead
37 lines
708 B
JavaScript
37 lines
708 B
JavaScript
const express = require('express');
|
|
|
|
const SetupService = require('../../../services/setup');
|
|
|
|
const router = express.Router();
|
|
|
|
router.get('/', async (req, res, next) => {
|
|
try {
|
|
await SetupService.isAvailable();
|
|
res.json({installed: false});
|
|
} catch (e) {
|
|
res.json({installed: true});
|
|
}
|
|
});
|
|
|
|
router.post('/', async (req, res, next) => {
|
|
try {
|
|
await SetupService.isAvailable();
|
|
} catch (e) {
|
|
return next(e);
|
|
}
|
|
|
|
const {
|
|
settings,
|
|
user: {email, password, username}
|
|
} = req.body;
|
|
|
|
try {
|
|
await SetupService.setup({settings, user: {email, password, username}});
|
|
res.status(204).end();
|
|
} catch (err) {
|
|
return next(err);
|
|
}
|
|
});
|
|
|
|
module.exports = router;
|