-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (35 loc) · 1.24 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
39
40
41
42
43
44
const express = require("express");
const bodyParser = require("body-parser");
const morgan = require("morgan");
const app = express();
const db = require("./model/index");
const TopicController = require("./controllers/topic");
const GrammarController = require("./controllers/grammar");
const IrregularController = require("./controllers/irregular");
const TestController = require("./controllers/test");
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(morgan("tiny"));
app.use("/ping", (req, res) => {
res.send("pong");
})
app.get("/topics", TopicController.getTopic);
app.get("/topics/:id_topic", TopicController.getWordFromTopic);
app.get("/list-grammar", GrammarController.getListGrammar);
app.get("/grammar", GrammarController.getContent);
app.get("/irregular", IrregularController.getIrregular);
app.get("/tests", TestController.getTests);
app.get("/tests/:id_test/questions", TestController.getQuestionFromTest);
db.sequelize.sync({
force: false
})
.then(() => {
console.log("Connect db success.")
app.listen(3000, () => {
console.log("Server running on 3000");
})
})
.catch(e => {
console.error(e.message);
process.exitCode(1);
})