-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (36 loc) · 1.02 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
import express from 'express';
import { MongoClient } from 'mongodb';
import dotenv from 'dotenv'
import cors from 'cors'
import {signup,bookYourSeats,getonemovie,home} from './router.js'
import {logins} from './loginrouter.js'
//variables
var app = express()
dotenv.config()
app.use(express.json());
app.use(cors())
//var mongoUrl="mongodb://localhost"
var mongoUrl = process.env.mongoUrl
//create server with mongo
async function createConnection(){
var client = new MongoClient(mongoUrl);
await client.connect()
console.log("connection is ready ")
return client
}
export var client = await createConnection()
app.use("/home",home)
app.use("/bookYourSeats",bookYourSeats)
app.use("/bookYourSeats",getonemovie)
app.use("/signup",signup)
//book your seats
app.use("/login",logins)
// addMovie
app.post("/admin/addMovie",async function(req,res){
var data = req.body
let result =await client.db("movie").collection("mov").insertOne({data})
res.send(result)
})
//sign
//login
app.listen(process.env.PORT)