mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-09 19:22:51 +00:00
fix: wait for config file validation
This commit is contained in:
committed by
Rainer Killinger
parent
90822f5888
commit
30082f8726
12
src/app.ts
12
src/app.ts
@@ -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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user