forked from velrino/cyberpunk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (29 loc) · 876 Bytes
/
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
const express = require('express');
const routes = require("./src/infrastructure/routes");
const typeorm = require("typeorm");
const Helpers = require("./src/infrastructure/helpers");
typeorm.createConnection({
type: "postgres",
host: "127.0.0.1",
port: 5432,
username: "postgres",
password: "root",
database: "cart",
synchronize: true,
logging: false,
//entities: Helpers.entities()
}).then(async connection => {
var bodyParser = require('body-parser')
var app = express();
app.use(bodyParser.json());
routes.forEach(route => {
app[route.method](route.path, (request, response, next) => {
route.action(request, response)
.then(() => next)
.catch(err => next(err));
});
});
app.listen(3000, function () {
console.log('Port 3000!');
});
}).catch(error => console.log("TypeORM connection error: ", error));