-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (28 loc) · 889 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// const express = require("express");
// const colors = require("colors");
import express from 'express';
import colors from 'colors';
import dotenv from 'dotenv';
import morgan from 'morgan';
import connectDB from './config/db.js';
import authRoutes from './routes/authRoutes.js';
import categoryRoutes from './routes/categoryRoutes.js';
import productRoutes from './routes/productRoutes.js'
import cors from 'cors';
const app = express();
dotenv.config();
connectDB();
app.use(cors());
app.use(express.json());
app.use(morgan('tiny'));
// routes
app.use('/api/v1/auth',authRoutes);
app.use('/api/v1/category',categoryRoutes);
app.use('/api/v1/product',productRoutes);
app.get("/",(req,res)=>{
res.send("<h1>Helloo And Welcome to rutu</h1>");
})
const PORT = process.env.PORT || 8080 ;
app.listen(PORT,()=>{
console.log(`server is running on ${PORT}`.bgCyan.bold.white);
})