-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.js
30 lines (24 loc) · 810 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
const express = require("express");
const path = require('path')
const cors = require('cors')
const requestLogger = require("./utils/requestLogger");
const authRoute = require('./routes/authRoute')
const userRoute = require('./routes/userRoute');
const postRoute = require('./routes/postRoute')
const errorHandler = require("./utils/errorHandler");
const app = express();
app.use(cors())
app.use(express.json())
app.use(requestLogger)
app.use(express.static("client/build"));
app.get("/api", (_, res) => {
res.send(`<code>Welcome to AUL forum API<code>`)
})
app.use("/api/auth", authRoute)
app.use("/api/users", userRoute)
app.use("/api/posts", postRoute)
app.use(errorHandler)
app.use("*", (_, res) => {
res.sendFile(path.join(__dirname, 'client', 'build', 'index.html'))
})
module.exports = app