You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.1 KiB
JavaScript

// packages
import path from 'path'
import express from 'express'
import dotenv from 'dotenv'
import cookieParser from 'cookie-parser'
// utils
import connectDB from './config/db.js'
import userRoute from './routes/userRoute.js'
import categoryRoute from './routes/categoryRoute.js'
import productRoute from './routes/productRoute.js'
import uploadRoute from './routes/uploadRoute.js'
import orderRoutes from "./routes/orderRoute.js";
dotenv.config()
const port = process.env.PORT || 4000
connectDB()
const app = express()
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.use(cookieParser())
app.use('/b6/users', userRoute)
app.use('/b6/category', categoryRoute)
app.use('/b6/products', productRoute)
app.use('/b6/upload', uploadRoute)
app.use("/b6/orders", orderRoutes);
app.get('/b6/config/paypal', (req, res) => {
res.send({clientId: process.env.PAYPAL_CLIENT_ID})
})
const __dirname = path.resolve()
app.use('/uploads', express.static(path.join(__dirname, '/uploads')))
app.listen(port, () => console.log(`Server running on port: ${port}`))