-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
48 lines (39 loc) 路 1.35 KB
/
Copy pathmain.ts
File metadata and controls
48 lines (39 loc) 路 1.35 KB
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
/**
* This is not a production server yet!
* This is only a minimal backend to get started.
*/
import { Logger, ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { ExpressAdapter } from '@nestjs/platform-express';
import cookieParser from 'cookie-parser';
import express from 'express';
import * as functions from 'firebase-functions';
import { GithubModule } from './modules/github/github.module';
import { setupAxios } from './setup/axios';
import { setupSwagger } from './setup/swagger';
const server = express();
async function bootstrap() {
const app = await NestFactory.create(GithubModule, new ExpressAdapter(server), { cors: true });
const globalPrefix = 'api';
const port = process.env.PORT || 3000;
app.setGlobalPrefix(globalPrefix);
app.use(cookieParser());
app.useGlobalPipes(
new ValidationPipe({
transform: true,
}),
);
// set up other services and tools running together with the app
setupSwagger(app);
setupAxios();
return { app, port, globalPrefix };
}
bootstrap()
.then(async ({ app, port, globalPrefix }) => {
await app.listen(port, () => Logger.log(`馃殌 Application is running on: http://localhost:${port}/${globalPrefix}`));
})
.catch((error) => {
Logger.error('Error starting the application', error);
});
// Firebase integration
export const api = functions.https.onRequest(server);