-
Notifications
You must be signed in to change notification settings - Fork 13
/
app.ts
48 lines (44 loc) · 1.22 KB
/
app.ts
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { KitesFactory, KitesInstance } from '@kites/core';
import Express from '@kites/express';
import Rest from '@kites/rest';
import mongoose from 'mongoose';
import { MongoDbServerDev, appRoutes } from './content/extensions';
import {
WordFeatures, IntentService, IntentClassifier, IobParser,
SequenceLabeler, NerService, NLUService,
} from './api';
async function bootstrap() {
const app = await KitesFactory
.create({
loadConfig: true,
providers: [
WordFeatures,
IntentClassifier,
IobParser,
SequenceLabeler,
IntentService,
NerService,
NLUService,
],
})
.use(Express)
.use(Rest)
.use(appRoutes)
.use(MongoDbServerDev)
.on('db:connect', (uri: string, kites: KitesInstance) => {
if (typeof uri === 'string') {
mongoose.connect(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
});
kites.logger.info('Mongodb connect ok: ' + uri);
} else {
// get connection string from kites.config
kites.logger.error('Please config mongodb connection!!!');
}
})
.init();
app.logger.info(`Server started!`);
}
bootstrap();