0db3d677b2
Reviewed-on: #4 Co-authored-by: Joseph Nelson <joseph.nelson4456@gmail.com> Co-committed-by: Joseph Nelson <joseph.nelson4456@gmail.com>
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
import express from 'express'
|
|
import path from 'path'
|
|
import cors from 'cors'
|
|
import healthCheckRoutes from './routes/healthcheck'
|
|
import authRoutes from './routes/auth'
|
|
import userRoutes from './routes/users'
|
|
import roleRoutes from './routes/roles'
|
|
import locationRoutes from './routes/locations'
|
|
import imageRoutes from './routes/images'
|
|
|
|
const app = express()
|
|
const port = process.env.PORT || 3000
|
|
|
|
// Middleware
|
|
app.use(express.json()) // For parsing application/json
|
|
app.use(express.urlencoded({ extended: true })) // For parsing URL-encoded form data
|
|
app.use(cors())
|
|
|
|
// Mount Routes
|
|
app.use('/healthcheck', healthCheckRoutes)
|
|
app.use('/auth', authRoutes)
|
|
app.use('/users', userRoutes)
|
|
app.use('/roles', roleRoutes)
|
|
app.use('/locations', locationRoutes)
|
|
app.use('/images', imageRoutes)
|
|
|
|
// Default Route (Catch-all for undefined routes)
|
|
app.use((req, res, next) => {
|
|
res.status(404).send('Sorry, the resource you requested could not be found.')
|
|
})
|
|
|
|
app.listen(port, () => {
|
|
console.log(`Server listening on port ${port}`)
|
|
})
|
|
|
|
export default app
|