Skip to content

Commit

Permalink
deploy to now.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
kingRayhan committed May 18, 2019
1 parent d992ca9 commit b9c466f
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PORT=4200
DB_URI=mongodb://localhost:27017/quran
DB_URI=mongodb://quran:[email protected]:47665/quran
SECRET=alksdjflajldkfjlakdflkj
10 changes: 7 additions & 3 deletions db-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ dir.forEach(file => {

npmScripts += `npm run import-${name} && `

console.log(
`"import-${name}":"mongorestore -d quran -c ${name} database/${file}",`
)
const importScript = `"import-${name}":"mongorestore -h ds347665.mlab.com:47665 -d quran -u quran -p quran123 database/${file}",`

console.log(importScript)

// console.log(
// `"import-${name}":"mongorestore -d quran -c ${name} database/${file}",`
// )
}
})

Expand Down
7 changes: 4 additions & 3 deletions dbconnect.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//Import mongoose library
const mongoose = require('mongoose');
const mongoose = require('mongoose')

//connect db
mongoose.connect(process.env.DB_URI, { useNewUrlParser: true })
mongoose
.connect(process.env.DB_URI, { useNewUrlParser: true })
.then(res => {
console.log('database connected')
})
.catch(err => {
console.log('database disconnected')
})
})
2 changes: 1 addition & 1 deletion gql-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const server = new GraphQLServer({

server.start(
{
port: 5000,
port: process.env.PORT || 5000,
},
({ port }) => {
console.log('Server working at http://localhost:' + port)
Expand Down
3 changes: 2 additions & 1 deletion now.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"version": 1,
"name": "quran-graphql-api"
"name": "quran-graphql-api",
"alias": "quran-project-gql"
}
27 changes: 14 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
"author": "anwarulislam",
"license": "MIT",
"scripts": {
"start": "nodemon index.js",
"import-ayah": "mongorestore -d quran -c ayah database/ayah.bson",
"import-bookmarks": "mongorestore -d quran -c bookmarks database/bookmarks.bson",
"import-corpus": "mongorestore -d quran -c corpus database/corpus.bson",
"import-footnotes_mhk": "mongorestore -d quran -c footnotes_mhk database/footnotes_mhk.bson",
"import-notes": "mongorestore -d quran -c notes database/notes.bson",
"import-quran_index": "mongorestore -d quran -c quran_index database/quran_index.bson",
"import-surah": "mongorestore -d quran -c surah database/surah.bson",
"import-tafsir_kathir": "mongorestore -d quran -c tafsir_kathir database/tafsir_kathir.bson",
"import-tafsir_kathir_segment": "mongorestore -d quran -c tafsir_kathir_segment database/tafsir_kathir_segment.bson",
"import-tr_en_sahih": "mongorestore -d quran -c tr_en_sahih database/tr_en_sahih.bson",
"import-verb_with_forms": "mongorestore -d quran -c verb_with_forms database/verb_with_forms.bson",
"import-words": "mongorestore -d quran -c words database/words.bson",
"start": "node gql-server",
"dev": "nodemon gql-server",
"import-ayah": "mongorestore -h ds347665.mlab.com:47665 -d quran -u quran -p quran123 database/ayah.bson",
"import-bookmarks": "mongorestore -h ds347665.mlab.com:47665 -d quran -u quran -p quran123 database/bookmarks.bson",
"import-corpus": "mongorestore -h ds347665.mlab.com:47665 -d quran -u quran -p quran123 database/corpus.bson",
"import-footnotes_mhk": "mongorestore -h ds347665.mlab.com:47665 -d quran -u quran -p quran123 database/footnotes_mhk.bson",
"import-notes": "mongorestore -h ds347665.mlab.com:47665 -d quran -u quran -p quran123 database/notes.bson",
"import-quran_index": "mongorestore -h ds347665.mlab.com:47665 -d quran -u quran -p quran123 database/quran_index.bson",
"import-surah": "mongorestore -h ds347665.mlab.com:47665 -d quran -u quran -p quran123 database/surah.bson",
"import-tafsir_kathir": "mongorestore -h ds347665.mlab.com:47665 -d quran -u quran -p quran123 database/tafsir_kathir.bson",
"import-tafsir_kathir_segment": "mongorestore -h ds347665.mlab.com:47665 -d quran -u quran -p quran123 database/tafsir_kathir_segment.bson",
"import-tr_en_sahih": "mongorestore -h ds347665.mlab.com:47665 -d quran -u quran -p quran123 database/tr_en_sahih.bson",
"import-verb_with_forms": "mongorestore -h ds347665.mlab.com:47665 -d quran -u quran -p quran123 database/verb_with_forms.bson",
"import-words": "mongorestore -h ds347665.mlab.com:47665 -d quran -u quran -p quran123 database/words.bson",
"seed-data": "npm run import-ayah && npm run import-bookmarks && npm run import-corpus && npm run import-footnotes_mhk && npm run import-notes && npm run import-quran_index && npm run import-surah && npm run import-tafsir_kathir && npm run import-tafsir_kathir_segment && npm run import-tr_en_sahih && npm run import-verb_with_forms && npm run import-words"
},
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion resolvers/Query.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ const Query = {

filter.sura = suraId

//TODO: Pagination to graphql api
if (verseNo) filter.ayah = verseNo

const ayah = await Surah.find(filter)

const filtered = ayah.slice(pageNo * limit - 1, limit)

console.log(JSON.stringify(ayah, undefined, 4))
return ayah
},
}

Expand Down

1 comment on commit b9c466f

@vercel
Copy link

@vercel vercel bot commented on b9c466f May 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deployment failed with the following error:

You tried to create a Now 1.0 deployment. Please use Now 2.0 instead: https://zeit.co/upgrade

Please sign in to comment.