-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrease.create.ts
41 lines (36 loc) · 956 Bytes
/
grease.create.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
/**
* @file createGreaser
* @module grease/create
*/
import { LoggerService, UserLogLevel } from '#src/log'
import type { INestApplicationContext as App } from '@nestjs/common'
import { NestFactory } from '@nestjs/core'
import GreaseModule from './grease.module'
import GreaseService from './grease.service'
/**
* Create a greaser.
*
* @see {@linkcode GreaseService}
*
* @async
*
* @return {Promise<GreaseService>} Grease runner instance
*/
const createGreaser = async (): Promise<GreaseService> => {
/**
* NestJS application context.
*
* @const {App} app
*/
const app: App = await NestFactory.createApplicationContext(GreaseModule, {
abortOnError: false,
autoFlushLogs: false,
bufferLogs: true
})
// use custom logger
app.useLogger(app.get(LoggerService).withTag('nest'))
app.useLogger([UserLogLevel.WARN])
app.flushLogs()
return (await app.init()).get(GreaseService)
}
export default createGreaser