Files
talk/routes/api/setup/index.js
T
Wyatt Johnson 745c579b82 Adjust redis to not start during webpack build
- 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
2017-07-17 13:34:04 -06:00

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;