-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
59 lines (42 loc) · 1.22 KB
/
index.js
File metadata and controls
59 lines (42 loc) · 1.22 KB
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
import express from 'express';
import bodyParser from 'body-parser'
import expressGraphQl from 'express-graphql'
import mongoose from 'mongoose'
import cors from 'cors'
import graphQLSchema from './graphql/schema'
import graphQLResolvers from './graphql/resolvers'
require('dotenv').config()
//importing the controller
import {getPlaySToreData} from '../server/controller/playstore_app'
const app=express()
//using cors :
app.use(cors(),
bodyParser.json())
//graphql
app.use("/graphql",
expressGraphQl({
schema:graphQLSchema,
rootValue:graphQLResolvers,
graphiql:true
}))
app.use('/root',async (req,res)=>{
console.log("hello")
let results = await getPlaySToreData()
// console.log(results)
res.json(results)
})
function main(){
const port = process.env.PORT || 8080
const uri = `mongodb+srv://${process.env.DB_USER}:${process.env.DB_PASS}@cluster0-taxoy.mongodb.net/test?retryWrites=true&w=majority`
const uri2 = "mongodb://127.0.0.1:27017/mern-graphql"
mongoose.connect(uri2,{useNewUrlParser:true})
.then(()=>{
app.listen(port,()=>{
console.log(`Servet running on port ${port}`)
})
})
.catch(err=>{
console.log(err)
})
}
main()