-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (28 loc) · 1.02 KB
/
server.js
File metadata and controls
37 lines (28 loc) · 1.02 KB
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
35
36
37
const express = require('express');
const mongoose = require('mongoose');
const cors = require('cors');
const dotenv = require('dotenv');
const authRoutes = require('./routes/auth');
const productRoutes = require('./routes/products');
const userRoutes = require('./routes/user');
// const express = require('express');
// const swaggerapp = express();
const app = express();
const { swaggerUi, swaggerSpec } = require('./swagger');
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
// Your other routes and middleware
// const cartRoutes = require('./routes/cart');
dotenv.config();
// const app = express();
app.use(cors());
app.use(express.json());
app.use('/api/auth', authRoutes);
app.use('/api/user', userRoutes);
app.use('/api/products', productRoutes);
// app.use('/api/cart', cartRoutes );
//starting the server
app.get('/', (req, res) => {
res.send('Server is running!');
});
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {console.log(`🚀 Server running at http://localhost:${PORT}`)});