diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-03-06 23:23:50 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-03-06 23:23:50 +0900 |
| commit | bbf4e1c41339738ce2563c3c7ae427ba4997bf3f (patch) | |
| tree | c5eef8f849916ea9af08af1c9b9e5b476a9b7ae6 | |
| parent | Clean up (diff) | |
| download | sharkey-bbf4e1c41339738ce2563c3c7ae427ba4997bf3f.tar.gz sharkey-bbf4e1c41339738ce2563c3c7ae427ba4997bf3f.tar.bz2 sharkey-bbf4e1c41339738ce2563c3c7ae427ba4997bf3f.zip | |
Add fallback for broken db
| -rw-r--r-- | src/models/app.ts | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/models/app.ts b/src/models/app.ts index 5c8d2cbd56..45d50bccda 100644 --- a/src/models/app.ts +++ b/src/models/app.ts @@ -4,6 +4,7 @@ import AccessToken from './access-token'; import db from '../db/mongodb'; import isObjectId from '../misc/is-objectid'; import config from '../config'; +import { dbLogger } from '../db/logger'; const App = db.get<IApp>('apps'); 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 _app.id = _app._id; delete _app._id; |