-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
32 lines (27 loc) · 888 Bytes
/
main.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
import {NestFactory} from '@nestjs/core'
import {AppModule} from './app.module'
export async function bootstrapNestjs() {
const app = await NestFactory.create(AppModule)
const SERVER_PORT = process.env.PORT || 3000
const SERVER_URL = `http://127.0.0.1:${SERVER_PORT}`
await app.listen(SERVER_PORT)
let logMessage = ''
// console.log('[bootstrapNestjs env]', process.env)
logMessage += `Server running at ${SERVER_URL}`
console.log(logMessage)
if (!process.env.JWT_SECRET) {
const msg = 'Error! Must set JWT_SECRET'
logMessage += '\n' + msg
console.error(msg)
}
if (!process.env.AUTH_USERS) {
const url = `${SERVER_URL}/#/gen`
const msg = `Error! Must set AUTH_USERS, please add them in .env file!\nYou can generate .env file at WebUI: ${url}`
logMessage += '\n' + msg
console.error(msg)
}
return {
app,
logMessage,
}
}