-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
46 lines (38 loc) · 1.06 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
import path from 'path';
import cors from 'cors';
import bodyParser from 'body-parser';
import ExpressJS from 'express';
import morgan from 'morgan';
import { fileURLToPath } from 'url';
let __dirname = path.dirname(fileURLToPath(import.meta.url));
import dotenv from "dotenv";
dotenv.config();
const AppExpress = ExpressJS();
let Config = {
debug: false,
canary: true,
port: process.env.PORT || 3535,
getUrl: () => {
return 'http://localhost:3535/';
}
};
if (Config.port === 3535) {
Config.debug = true;
};
console.log(`Hey! I'll use this port ${Config.port}`);
AppExpress.use(cors());
AppExpress.use(morgan('combined'));
AppExpress.use(bodyParser.urlencoded({ extended: false }));
AppExpress.use(bodyParser.json());
var Server = AppExpress.listen(Config.port, (err) => {
if (err) {
console.error(`Error opening server`, err);
return;
};
console.log(`Open server on port ${Config.port} -> http://localhost:${Config.port}/`);
});
AppExpress.get(`/`, (req, res) => {
res.send({
msg: `Hi Jarlini`
});
});