-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (38 loc) · 1.04 KB
/
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
36
37
38
const express = require("express");
const app = express();
var session = require("express-session");
const route = require("./routes/index.route");
require("./db/connect");
require("dotenv").config();
const cors = require("cors");
const table = require("./model/index");
const socket = require("./socket.io/connect.socket");
const path = require("path");
var session = require("express-session");
app.use("/", express.static(__dirname + "/"));
app.use(
session({
secret: "keyboard cat",
resave: false,
saveUninitialized: false,
})
);
var server = require("http").createServer(app);
const port = process.env.PORT || 1000;
app.use(
cors({
origin: ["http://localhost:3000"],
credentials: true,
})
);
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use("/images", express.static(path.join(__dirname, "images")));
route(app);
table.create().then(() => {
console.log(`create table successfully !`);
});
socket.connect(server);
server.listen(port, function () {
console.log(`listening on *:${port}`);
});