-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
31 lines (24 loc) · 774 Bytes
/
server.ts
File metadata and controls
31 lines (24 loc) · 774 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
31
import express, { Express, Request, Response } from 'express';
import cors from 'cors';
import dotenv from 'dotenv';
import connectDB from './config/db';
import recordRoutes from './routes/record.routes';
dotenv.config();
const app: Express = express();
const PORT = process.env.PORT || 3000;
// Connect to Database
connectDB();
// Middleware
app.use(cors());
app.use(express.json()); // For parsing JSON bodies
app.use(express.urlencoded({ extended: true })); // For parsing URL-encoded data
// Routes
app.use('/api/records', recordRoutes);
// Root Endpoint
app.get('/', (req: Request, res: Response) => {
res.send('CloudKeep Server is Running');
});
// Start Server
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});