-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
executable file
·55 lines (42 loc) · 1.11 KB
/
index.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
require('@dotenvx/dotenvx').config();
import express from "express";
import cors from "cors";
import config from "config";
import TestRouter from "./src/routers/test";
import TeacherRouter from "./src/routers/teacher";
import swaggerJSDoc, { Options } from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';
const swaggerDefinition = {
openapi: '3.0.0',
info: {
title: 'Feedback API',
version: '1.0.0',
},
servers: [
{
url: '/api',
},
],
};
const options: Options = {
swaggerDefinition,
apis: ['./src/routers/*.ts'],
};
const swaggerSpec = swaggerJSDoc(options);
//instância da apliacação
const app = express();
//middleware - trafegar informações em json
app.use(express.json());
///middleware - cors
app.use(cors({
credentials: true,
origin: process.env.ORIGIN_URL
}));
app.use("/api/", TeacherRouter);
app.use("/api/", TestRouter);
app.use('/api/docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
//importando a porta do config
const port = config.get<number>("port");
app.listen(port, async () => {
console.log(`App running / Port: ${port}`)
});