Completed the server setup for health checkup
This commit is contained in:
29
server/src/server.ts
Normal file
29
server/src/server.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import express, {Application, Request, Response} from 'express';
|
||||
import cors from 'cors';
|
||||
import {ENV} from './config/env';
|
||||
import connectDB from './config/db';
|
||||
|
||||
const app: Application = express()
|
||||
|
||||
app.use(cors ())
|
||||
app.use(express.json())
|
||||
|
||||
app.get('/health', (_req: Request, res: Response)=> {
|
||||
res.json({
|
||||
status: 'ok',
|
||||
environment: ENV.NODE_ENV,
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//start Server
|
||||
|
||||
const start = async (): Promise<void> => {
|
||||
await connectDB();
|
||||
app.listen(ENV.PORT, () => {
|
||||
console.log(`Server running on port ${ENV.PORT}`)
|
||||
});
|
||||
};
|
||||
|
||||
start();
|
||||
Reference in New Issue
Block a user