-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
66 lines (54 loc) · 2.27 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
55
56
57
58
59
60
61
62
63
64
65
66
console.log("\nIndex is beeing read ...\n") ;
import HoraryPriceRouter from './routes/HoraryPriceRoute';
import ActivityRouter from "./routes/ActivityRoute";
import ProductRouter from "./routes/ProductRoute";
import SubscriptionPriceRouter from "./routes/SubscriptionPriceRoute";
import TimeSlotRouter from "./routes/TimeSlotRoute";
import ServiceRouter from "./routes/ServiceRoute";
import MealTrayRouter from "./routes/MealTrayRoute";
import BookableRouter from "./routes/BookableRoute";
import CardRouter from "./routes/CardRoute";
import UserRouter from "./routes/UserAccountRoute";
import RegistrationRouter from "./routes/RegistrationRoute";
import SpaceRouter from "./routes/SpaceRoute";
import express, {Response, Request} from 'express';
import mongoose from "mongoose";
import dotenv from 'dotenv';
import cors from 'cors';
dotenv.config();
const MONGO_URL = process.env.MONGO_URL || "mongodb+srv://blaze940:[email protected]/?retryWrites=true&w=majority";
const PORT = process.env.PORT || 5000;
const app = express();
//use cors middleware to allow cross-origin resource sharing
app.use(cors());
//Retrieve the body of the request
app.use(express.json());
//////////////////////////////////////////////////////////////////////////////////////////////
//First route test
// app.use("/API", (req: Request, res: Response) => {
// //console.log("\nFirst Route succeed");
// res.send("Connected to API Co'Work sucessfully !");
// });
//Use des routes de bases
app.use("/API/horaryPrice", HoraryPriceRouter);
app.use("/API/activity", ActivityRouter);
app.use("/API/product", ProductRouter);
app.use("/API/subscriptionPrice", SubscriptionPriceRouter);
app.use("/API/timeSlot", TimeSlotRouter);
app.use("/API/service", ServiceRouter);
app.use("/API/mealTray", MealTrayRouter);
app.use("/API/bookable", BookableRouter);
app.use("/API/card", CardRouter);
app.use("/API/user", UserRouter);
app.use("/API/registration", RegistrationRouter);
app.use("/API/space", SpaceRouter);
//Connexion MongoDb
mongoose.connect(MONGO_URL,{})
.then(() => {
console.log("Connected to MongoDB");
app.listen(PORT, () => {
console.log('Server listening on port ' + PORT);
});
}).catch(() => {
throw new Error('Couldn\'t connect to the server')
});