-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (24 loc) · 772 Bytes
/
index.js
File metadata and controls
30 lines (24 loc) · 772 Bytes
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
import express from 'express';
import dotenv from 'dotenv';
import cors from 'cors';
import helmet from 'helmet';
import authRoutes from './src/routes/authRoutes.js';
import userRoutes from './src/routes/userRoutes.js';
import { swaggerUi, swaggerSpec } from './src/config/swagger.js';
dotenv.config();
const app = express();
app.use(express.json());
// security middleware
app.use(cors({
origin: 'http://localhost:3000',
methods: ['GET', 'POST', 'PUT', 'DELETE'],
}))
app.use(helmet());
// Swagger
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
// routes
app.use('/api/auth', authRoutes);
app.use('/api/users', userRoutes);
app.listen(process.env.PORT || 5000, () => {
console.log(`Server running on port ${process.env.PORT}`);
});