27 lines
733 B
JavaScript
27 lines
733 B
JavaScript
import express from 'express'
|
|
import path from 'path'
|
|
import cors from 'cors'
|
|
import healthCheckRoutes from './routes/healthcheck'
|
|
import authRoutes from './routes/auth'
|
|
|
|
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)
|
|
|
|
// 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}`)
|
|
})
|