forked from Sunbird-ALL/all-rig-points-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
43 lines (32 loc) · 976 Bytes
/
index.ts
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
38
39
40
41
import express from "express";
// import bcrypt from "bcryptjs";
import mongoose from "mongoose";
import cors from "cors"
import router from "./src/modules";
import * as dotenv from 'dotenv';
dotenv.config();
const PORT: number = parseInt(process.env.PORT || '3000');
const MONGO_URL: string = process.env.MONGO_URL || 'mongodb://0.0.0.0:27017/lesson_points_tracker';
export const app = express();
// parsing the request data
app.use(express.json());
app.use(cors());
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
// dataBase connection
mongoose.set('strictQuery', false);
mongoose.connect(MONGO_URL).then(()=>{
console.log("\n*************MONGODB connected**************\n");
}).catch(error =>{
console.log("unable to connect with database:", error);
});
// App testing
app.get('/ping', (req,res)=>{
res.status(200).json({
status: true,
message : "App is working",
})
});
// router
app.use("/api", router);