fix: wait for config file validation

This commit is contained in:
Anselm Stordeur
2019-01-14 16:45:07 +01:00
committed by Rainer Killinger
parent 90822f5888
commit 30082f8726

View File

@@ -36,6 +36,7 @@ import {Elasticsearch} from './storage/elasticsearch/Elasticsearch';
export const app = express();
async function configureApp() {
// only accept json as content type for all requests
app.use(bodyParser.json({
limit: '500kb',
@@ -59,8 +60,8 @@ const databases: {[name: string]: DatabaseConstructor} = {
};
// validate config file
export const scValidator = new Validator();
scValidator.addSchemas(join('node_modules', '@openstapps', 'core', 'lib', 'schema'));
const scValidator = new Validator();
await scValidator.addSchemas(join('node_modules', '@openstapps', 'core', 'lib', 'schema'));
// validate the config file
const configValidation = scValidator.validate(config.util.toObject(), 'SCConfigFile');
@@ -156,3 +157,10 @@ app.use((_req, res) => {
});
// TODO: implement a route to register plugins
}
configureApp().then(() => {
logger.ok('Sucessfully configured express server');
}).catch((err) => {
throw err;
});