-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (45 loc) · 1.47 KB
/
index.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const express=require("express");
const app=express();
const swaggerjsdoc=require("swagger-jsdoc");
const swaggerui=require("swagger-ui-express");
require('dotenv').config()
app.use(express.json());
const {connection}=require("./config/config")
const {userrouter}=require("./routes/credential.route")
const {Resrouter}=require("./routes/restaurent.router")
app.use("/api",userrouter)
app.use("/api",Resrouter)
//===================================================> swagger code
const options={
definition:{
openapi: "3.0.0",
info:{
title:"food ordering api doc",
version:"0.1",
description:
"This is a food order website where u can order food by registering and login using following end points ",
contact:{
name:"sriram",
CourseID:"fw22_0103",
email:"[email protected]"
}
},
servers:[
{
url:"https://mock7-hkq8.onrender.com/"
},
],
},
apis:["./routes/*.js"]
}
const spacs=swaggerjsdoc(options);
app.use("/api-docs",swaggerui.serve,swaggerui.setup(spacs))
//==================================================================================
app.listen(process.env.port,async()=>{
try {
await connection;
console.log(`server running at ${process.env.port} \n database connected`)
} catch (error) {
console.log(error.message)
}
})