Browse Source

Refuse to start if NOT migrated to TypeORM

pull/6/head
Menci 6 years ago
parent
commit
62f6c05ffe
  1. 12
      app.js
  2. 3
      config-example.json

12
app.js

@ -29,6 +29,16 @@ global.syzoj = {
if (obj instanceof ErrorMessage) return;
console.log(obj);
},
checkMigratedToTypeORM() {
const userConfig = require(options.config);
if (!userConfig.db.migrated_to_typeorm) {
app.use((req, res) => res.send('Please refer to <a href="https://github.com/syzoj/syzoj/wiki/TypeORM-%E8%BF%81%E7%A7%BB%E6%8C%87%E5%8D%97">TypeORM Migration Guide</a>.'));
app.listen(parseInt(syzoj.config.port), syzoj.config.hostname);
return false;
}
return true;
},
async run() {
// Check config
if (syzoj.config.session_secret === '@SESSION_SECRET@'
@ -42,6 +52,8 @@ global.syzoj = {
let Express = require('express');
global.app = Express();
if (!this.checkMigratedToTypeORM()) return;
syzoj.production = app.get('env') === 'production';
let winstonLib = require('./libs/winston');
winstonLib.configureWinston(!syzoj.production);

3
config-example.json

@ -6,7 +6,8 @@
"database": "syzoj",
"username": "syzoj",
"password": "@DATABASE_PASSWORD@",
"host": "127.0.0.1"
"host": "127.0.0.1",
"migrated_to_typeorm": true
},
"logo": {
"url": null,

Loading…
Cancel
Save