-
Notifications
You must be signed in to change notification settings - Fork 45
/
app.js
26 lines (22 loc) · 927 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';
const path = require('path');
const OAuth2Server = require('./lib/server');
module.exports = app => {
app.coreLogger.info('[egg-oauth2-server] egg-oauth2-server begin start');
const start = Date.now();
const config = app.config.oAuth2Server;
const model = app.loader.loadFile(path.join(app.config.baseDir, 'app/extend/oauth.js'))
// @see https://github.com/Azard/egg-oauth2-server/issues/31
|| app.loader.loadFile(path.join(app.config.baseDir, 'app/extend/oauth.ts'));
if (model === null) {
app.coreLogger.error('[egg-oauth2-server] not find app/extend/oauth.js, egg-oauth2-server start fail');
return;
}
try {
app.oAuth2Server = new OAuth2Server(config, model);
} catch (e) {
app.coreLogger.error('[egg-oauth2-server] start fail, %s', e);
return;
}
app.coreLogger.info('[egg-oauth2-server] egg-oauth2-server started use %d ms', Date.now() - start);
};