-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from PorePranav/main
Setup backend for vercel deployment
- Loading branch information
Showing
5 changed files
with
34 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ dist-ssr | |
*.sln | ||
*.sw? | ||
|
||
.env | ||
.env | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
# MongoDB Connection String | ||
DB_Url= | ||
|
||
# Port for your application | ||
PORT= | ||
|
||
# JWT Secret Key | ||
JWT_SECRET= | ||
|
||
|
||
|
||
NODE_ENV=development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,33 @@ | ||
import express from "express"; | ||
import { PORT, mongoDBUrl } from "./config.js"; | ||
import cors from "cors"; | ||
import mongoose from "mongoose"; | ||
//import registrationRoutes from './api/routes/registerRoute.js'; | ||
import patientRoutes from "./api/routes/PatientRoute.js"; | ||
import mongoose from 'mongoose'; | ||
import patientRoutes from './api/routes/PatientRoute.js'; | ||
|
||
const app = express(); | ||
|
||
//middleware | ||
app.use(express.json()); | ||
app.use(cors()); | ||
|
||
app.get("/", (req, res) => { | ||
return res.status(234).send("hello world"); | ||
app.get('/', (req, res) => { | ||
return res.status(234).send('hello world'); | ||
}); | ||
|
||
// Route handler | ||
app.use('/api/patients', patientRoutes); | ||
|
||
mongoose | ||
.connect(mongoDBUrl) | ||
.then(() => { | ||
console.log("App connected to database"); | ||
app.listen(PORT, () => { | ||
console.log(`App is listening to port: ${PORT}`); | ||
}); | ||
console.log('App connected to database'); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
}); | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
app.listen(PORT, () => { | ||
console.log(`App is listening to port: ${PORT}`); | ||
}); | ||
} | ||
|
||
export default app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"version": 2, | ||
"builds": [ | ||
{ | ||
"src": "server.js", | ||
"use": "@vercel/node" | ||
} | ||
], | ||
"routes": [ | ||
{ | ||
"src": "/(.*)", | ||
"dest": "server.js" | ||
} | ||
] | ||
} |