-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
51 lines (46 loc) · 1.76 KB
/
server.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
const express = require("express");
const app = express();
const cors = require('cors');
const dotenv = require("dotenv");
const sequelize = require("./config/db");
const authRoutes = require("./routes/auth");
const userRoutes = require("./routes/users");
const maintenanceRoutes = require("./routes/maintenance/maintenance");
const siteRoutes = require("./routes/sites");
const noteRoutes = require("./routes/maintenance/notes");
const clientRoutes = require("./routes/clients");
const estimateRoutes = require("./routes/estimate/estimate");
const estimateTaskRoutes = require("./routes/estimate/estimateTask");
const companyInfoRoutes = require("./routes/companyInfo");
const invoiceRoutes = require("./routes/invoice/invoice");
const invoiceTaskRoutes = require("./routes/invoice/invoiceTask");
const projectRoutes = require("./routes/project/project");
require("./cronJob");
require("./models/associations");
dotenv.config();
app.use(cors({ origin: 'http://localhost:8080' }));
app.use(express.json({ limit: '10mb' }));
// Routes
app.use("/api/auth", authRoutes);
app.use("/api/user", userRoutes);
app.use("/api/maintenance", maintenanceRoutes);
app.use("/api/site", siteRoutes);
app.use("/api/note", noteRoutes);
app.use("/api/client", clientRoutes);
app.use("/api/estimate", estimateRoutes);
app.use("/api/estimate-task", estimateTaskRoutes);
app.use("/api/company-info", companyInfoRoutes);
app.use("/api/invoice", invoiceRoutes);
app.use("/api/invoice-task", invoiceTaskRoutes);
app.use("/api/project", projectRoutes);
sequelize
.sync()
.then(() => {
console.log("Database synced successfully");
app.listen(3000, () => {
console.log("Server is running on http://localhost:3000");
});
})
.catch((err) => {
console.error("Unable to sync database:", err);
});