2017-10-22 09:10:33 +08:00
|
|
|
"use strict";
|
|
|
|
|
2017-10-16 05:31:49 +08:00
|
|
|
const express = require('express');
|
|
|
|
const router = express.Router();
|
2017-10-16 07:47:05 +08:00
|
|
|
const auth = require('../../services/auth');
|
2017-11-03 08:48:02 +08:00
|
|
|
const options = require('../../services/options');
|
2017-10-23 08:22:09 +08:00
|
|
|
const migration = require('../../services/migration');
|
2017-12-04 11:29:23 +08:00
|
|
|
const app_info = require('../../services/app_info');
|
2018-01-07 22:35:44 +08:00
|
|
|
const wrap = require('express-promise-wrap').wrap;
|
2017-10-16 05:31:49 +08:00
|
|
|
|
2018-01-07 22:35:44 +08:00
|
|
|
router.get('', auth.checkApiAuthForMigrationPage, wrap(async (req, res, next) => {
|
2017-10-16 05:31:49 +08:00
|
|
|
res.send({
|
2017-11-10 12:25:23 +08:00
|
|
|
db_version: parseInt(await options.getOption('db_version')),
|
2017-12-04 11:29:23 +08:00
|
|
|
app_db_version: app_info.db_version
|
2017-10-16 05:31:49 +08:00
|
|
|
});
|
2018-01-07 22:35:44 +08:00
|
|
|
}));
|
2017-10-16 05:31:49 +08:00
|
|
|
|
2018-01-07 22:35:44 +08:00
|
|
|
router.post('', auth.checkApiAuthForMigrationPage, wrap(async (req, res, next) => {
|
2017-10-23 08:22:09 +08:00
|
|
|
const migrations = await migration.migrate();
|
2017-10-16 05:31:49 +08:00
|
|
|
|
|
|
|
res.send({
|
2017-11-10 12:25:23 +08:00
|
|
|
migrations: migrations
|
2017-10-16 05:31:49 +08:00
|
|
|
});
|
2018-01-07 22:35:44 +08:00
|
|
|
}));
|
2017-10-16 05:31:49 +08:00
|
|
|
|
|
|
|
module.exports = router;
|