-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
38 lines (28 loc) · 773 Bytes
/
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
const express = require("express");
const path = require("path");
const app = express();
const { db } = require("./config/db");
const PORT = 3000;
// Initialization
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
const ImageDir = path.join(__dirname, "/Images");
app.use(express.static(ImageDir));
const ThumbDir = path.join(__dirname, "/Images/thumbnails");
app.use(express.static(ThumbDir));
const userRoute = require('./router/User');
app.use('/user', userRoute);
db.authenticate()
.then(() => {
console.log("Database connected");
})
.catch(err => {
console.log(err);
});
app.listen(PORT, err => {
if (err) {
console.log(`Error: ${err}`);
} else {
console.log(`Server is started on port ${PORT}`);
}
});