Add fallback for broken db
This commit is contained in:
parent
a24a20a83d
commit
bbf4e1c413
1 changed files with 7 additions and 0 deletions
|
@ -4,6 +4,7 @@ import AccessToken from './access-token';
|
||||||
import db from '../db/mongodb';
|
import db from '../db/mongodb';
|
||||||
import isObjectId from '../misc/is-objectid';
|
import isObjectId from '../misc/is-objectid';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
|
import { dbLogger } from '../db/logger';
|
||||||
|
|
||||||
const App = db.get<IApp>('apps');
|
const App = db.get<IApp>('apps');
|
||||||
App.createIndex('secret');
|
App.createIndex('secret');
|
||||||
|
@ -66,6 +67,12 @@ export const pack = (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// (データベースの欠損などで)アプリがデータベース上に見つからなかったとき
|
||||||
|
if (_app == null) {
|
||||||
|
dbLogger.warn(`[DAMAGED DB] (missing) pkg: app :: ${app}`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Rename _id to id
|
// Rename _id to id
|
||||||
_app.id = _app._id;
|
_app.id = _app._id;
|
||||||
delete _app._id;
|
delete _app._id;
|
||||||
|
|
Loading…
Reference in a new issue