/
main.ts
38 lines (34 loc) · 1010 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
33
34
35
36
37
38
import { NestFactory } from '@nestjs/core';
import {
FastifyAdapter,
NestFastifyApplication,
} from '@nestjs/platform-fastify';
import { join } from 'path';
import { AppModule } from './app.module';
import { ApiConfig, ApiConfigKit } from 'tnw';
async function bootstrap() {
// 亦可以读取配置文件
let apiConfig = new ApiConfig("Javen", "wx614c453e0d1dcd12", "19a02e4927d346484fc70327970457f9", false, "xxxx");
// 支持多公众号
ApiConfigKit.putApiConfig(apiConfig);
ApiConfigKit.setCurrentAppId();
// 开启开发模式,方便调试
ApiConfigKit.devMode = true;
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter(),
);
console.log("__dirname:", __dirname);
app.useStaticAssets({
root: join(__dirname, 'public'),
prefix: '/public/',
});
app.setViewEngine({
engine: {
handlebars: require('handlebars'),
},
templates: join(__dirname, 'views'),
});
await app.listen(8888);
}
bootstrap();