2023-06-20 20:05:15 +00:00
|
|
|
import 'dotenv/config'
|
|
|
|
|
|
|
|
import express from 'express'
|
2023-06-23 18:15:11 +00:00
|
|
|
import router from './routes'
|
2023-06-20 20:05:15 +00:00
|
|
|
import compression from 'compression'
|
2023-07-17 20:47:05 +00:00
|
|
|
import limiter from './middlewares/rate-limit'
|
2023-06-20 20:05:15 +00:00
|
|
|
|
|
|
|
const app = express()
|
|
|
|
|
2023-07-20 11:15:29 +00:00
|
|
|
// TODO: find a way to declare global variables for better refactor on test
|
|
|
|
// TODO: must pass userMock as a global
|
2023-07-17 20:47:05 +00:00
|
|
|
|
2023-06-20 20:05:15 +00:00
|
|
|
app.use(express.json())
|
|
|
|
app.use(express.urlencoded({ extended: true }))
|
|
|
|
app.use(router)
|
2023-07-17 20:47:05 +00:00
|
|
|
app.use(limiter)
|
2023-06-20 20:05:15 +00:00
|
|
|
app.use(compression({ level: 9 }))
|
|
|
|
|
|
|
|
app.use((_req, res) => {
|
|
|
|
res.status(404).json({
|
|
|
|
error: 'Not found'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
export default app
|