-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.js
50 lines (40 loc) · 1.57 KB
/
app.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
import express from "express";
import cors from "cors";
import bodyParser from "body-parser";
import { sequelize } from "./sequelize.js";
import { usersRouter } from "./Routes/usersRouter.js";
import { mainRouter } from "./Routes/mainRouter.js";
import { transportsByRouter } from "./Routes/trasnsportsByRouter.js";
import { satisfactionsRouter } from "./Routes/satisfactionsRouter.js";
import { agglomerationsRouter } from "./Routes/agglomerationsRouter.js";
import { experienceRouter } from "./Routes/experiencesRouter.js";
import { User } from "./Models/user.js";
import { TransportBy } from "./Models/transportBy.js";
import { Agglomeration } from "./Models/agglomeration.js";
import { Satisfaction } from "./Models/satisfaction.js";
import { Experience } from "./Models/experience.js";
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors());
//Associations
// un user poate avea mai multe experiente
User.hasMany(Experience);
Satisfaction.hasOne(Experience);
TransportBy.hasOne(Experience);
Agglomeration.hasOne(Experience);
app.use("/project", usersRouter);
app.use("/project", transportsByRouter);
app.use("/project", satisfactionsRouter);
app.use("/project", agglomerationsRouter);
app.use("/project", experienceRouter);
app.use("/project", mainRouter);
app.listen(5001, async () => {
console.log("Express web server running on port 5001");
try {
await sequelize.authenticate();
console.log("Connection has been established!");
} catch (err) {
console.err("Unable to connect to the database !", err);
}
});