-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
35 lines (23 loc) · 783 Bytes
/
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
const express = require("express");
const cors = require("cors");
const app = express();
const corsOptions = {
origin: `http://localhost:8081`
};
app.use(cors(corsOptions));
// parse requests of content-type - application/json
app.use(express.json());
// parse requests of content-type - application/x-www-form-urlencoded
app.use(express.urlencoded({ extended: true }));
app.get("/", (req, res) => {
res.status(200).send({ message: "Welcome to rock paper scissors game" });
});
require("./app/routes/article.route")(app)
app.all('*', (req, res) => {
res.status(200).send({ message: "Not Found" });
});
// set port, listen for requests
const PORT = process.env.PORT || 8000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}.`);
});