-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
57 lines (44 loc) · 1.36 KB
/
index.js
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
55
56
57
// Express routing module
import express, { json, urlencoded } from "express";
import fileUpload from "express-fileupload";
// .env file
import "dotenv/config.js";
// Pdf Reading module
import pkg from 'body-parser';
const { urlencoded: _urlencoded } = pkg;
// Variable app
const app = express();
import path from "path";
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
global.__dirname = path.dirname(__filename);
// Settings
app.set("port", 3000);
// Natural IA
import { mainNatural } from "./src/controller/natural.controller.js";
// winston logs file config
import logger from "./src/logs_module/logs.controller.js";
// Multer & Cors (GET/SET Read Documents)
global.__basedir = __dirname;
import cors from "cors";
const corsOptions = {
origin: "http://localhost:3001",
};
app.use(cors(corsOptions));
// Index Custom Routes
import initRoutes from "./src/routes/index.js";
import initRoutesSamples from "./src/routes/index.samples.js";
// Middleware api
app.use(json());
app.use(urlencoded({ extended: true }));
initRoutes(app);
// Middleware Web app
app.use(express.static(path.join(__dirname, "public")));
app.use(fileUpload());
app.use(_urlencoded({ extended: false }));
initRoutesSamples(app);
// Init IA Natural
mainNatural();
app.listen(app.get("port"), () => {
logger.info(`App listening in port: ${app.get("port")}`);
});