-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathapplication.ts
57 lines (49 loc) · 1.65 KB
/
application.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
49
50
51
52
53
54
55
56
57
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
// Node module: @loopback/example-todo
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
import {ApplicationConfig} from '@loopback/core';
import {RestApplication} from '@loopback/rest';
import {MySequence} from './sequence';
import {db} from './datasources/db.datasource';
/* tslint:disable:no-unused-variable */
// Binding and Booter imports are required to infer types for BootMixin!
import {BootMixin, Booter, Binding} from '@loopback/boot';
// juggler and DataSourceConstructor imports are required to infer types for RepositoryMixin!
import {
Class,
Repository,
RepositoryMixin,
juggler,
DataSourceConstructor,
} from '@loopback/repository';
/* tslint:enable:no-unused-variable */
export class TodoListApplication extends BootMixin(
RepositoryMixin(RestApplication),
) {
constructor(options?: ApplicationConfig) {
super(options);
// Set up the custom sequence
this.sequence(MySequence);
this.projectRoot = __dirname;
// Customize @loopback/boot Booter Conventions here
this.bootOptions = {
controllers: {
// Customize ControllerBooter Conventions here
dirs: ['controllers'],
extensions: ['.controller.js'],
nested: true,
},
};
this.setupDatasources();
}
setupDatasources() {
// This will allow you to test your application without needing to
// use a "real" datasource!
const datasource =
this.options && this.options.datasource
? new DataSourceConstructor(this.options.datasource)
: db;
this.dataSource(datasource);
}
}