-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
42 lines (33 loc) · 1.13 KB
/
server.js
File metadata and controls
42 lines (33 loc) · 1.13 KB
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
import 'dotenv/config.js'
import express from 'express'
import path from 'path'
import { fileURLToPath } from 'url'
import logger from 'morgan'
import cors from 'cors'
import { router as usersRouter } from './routes/users.js'
import { router as authRouter } from './routes/auth.js'
// milestone router
import {router as pathsRouter} from "./routes/paths.js"
import {router as skillsRouter} from "./routes/skills.js"
import {router as milestonesRouter} from "./routes/milestones.js"
import './config/database.js'
const app = express()
app.use(express.static(path.join(path.dirname(fileURLToPath(import.meta.url)),'build')))
app.use(cors())
app.use(logger('dev'))
app.use(express.json())
app.use('/api/auth', authRouter)
app.use('/api/users', usersRouter)
// USE ROUTES ADDED
app.use("/api/paths", pathsRouter)
app.use("/api/skills", skillsRouter)
app.use("/api/milestones", milestonesRouter)
app.get("/*", function (req, res) {
res.sendFile(
path.join(path.dirname(fileURLToPath(import.meta.url)), "build", "index.html")
)
})
const port = process.env.PORT || 3001
app.listen(port, () => {
console.log(`Express is listening on port ${port}.`)
})