-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
36 lines (28 loc) · 847 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
const express = require("express");
const {
handle500errors,
handle404errors,
handleCustomErrors,
handlePsqlErrors
} = require("./controllers/controllers.errors");
const {
getTopics,
getArticles,
getArticlesByArticleID,
getCommentsByArticleID,
postComment,
updateArticle
} = require("./controllers/controllers.app");
const app = express();
app.use(express.json());
app.get("/api/topics", getTopics);
app.get("/api/articles", getArticles);
app.get("/api/articles/:article_id", getArticlesByArticleID);
app.get("/api/articles/:article_id/comments", getCommentsByArticleID)
app.post("/api/articles/:article_id/comments", postComment);
app.patch("/api/articles/:article_id", updateArticle);
app.all("*",handle404errors);
app.use(handleCustomErrors)
app.use(handlePsqlErrors)
app.use(handle500errors);
module.exports = app;