added some base code to start doing work
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
const express = require('express')
|
||||
const path = require('path')
|
||||
|
||||
const authRoutes = require('./routes/auth')
|
||||
const productsRoutes = require('./routes/products')
|
||||
const usersRoutes = require('./routes/users')
|
||||
|
||||
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
|
||||
|
||||
// Static Files (Serving Frontend)
|
||||
app.use(express.static(path.join(__dirname, 'public')))
|
||||
|
||||
// Mount Routes
|
||||
app.use('/auth', authRoutes)
|
||||
app.use('/products', productsRoutes)
|
||||
app.use('/users', usersRoutes)
|
||||
|
||||
// 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}`)
|
||||
})
|
||||
Reference in New Issue
Block a user