-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8e647b3
Showing
17 changed files
with
17,945 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
PORT=4200 | ||
DB_URI=mongodb://localhost:27017/quran | ||
SECRET=alksdjflajldkfjlakdflkj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const Note = require('./../models/Note') | ||
|
||
module.exports.addNote = (req, res) => { | ||
res.json(req.body) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const Surah = require('./../models/Surah') | ||
|
||
module.exports.getAllSurah = async (req, res) => { | ||
var fs = require('fs'); | ||
|
||
// fs.readFile('./../surah.json', function (err, data) { | ||
// if (err) throw err; | ||
|
||
// console.log(data); | ||
// }) | ||
|
||
const surah = require('./../surah.json') | ||
|
||
res.json(surah) | ||
} | ||
|
||
module.exports.getSurah = async (req, res) => { | ||
const options = { | ||
page: req.query.p || 1, | ||
limit: 10, | ||
customLabels: 'hlaksdjf' | ||
}; | ||
let surah = await Surah.paginate({ sura: req.params.surah_no }, options, 5, (error, pageCount, paginatedResults) => { | ||
if (error) { | ||
console.error(error); | ||
} else { | ||
console.log('Pages:', pageCount); | ||
console.log(paginatedResults); | ||
} | ||
}) | ||
|
||
if (surah.prevPage) { | ||
surah.prevLink = req.protocol + '://' + req.get('host') + req.path + `?p=${surah.prevPage}` | ||
} | ||
if (surah.nextPage) { | ||
surah.nextLink = req.protocol + '://' + req.get('host') + req.path + `?p=${surah.nextPage}` | ||
} | ||
|
||
res.json(surah) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//Import mongoose library | ||
const mongoose = require('mongoose'); | ||
|
||
//connect db | ||
mongoose.connect(process.env.DB_URI, { useNewUrlParser: true }) | ||
.then(res => { | ||
console.log('database connected') | ||
}) | ||
.catch(err => { | ||
console.log('database disconnected') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const express = require('express') | ||
const app = express() | ||
const expressSession = require('express-session') | ||
const cookieParser = require('cookie-parser') | ||
|
||
require('dotenv').config() | ||
require('./dbconnect') | ||
|
||
app.use(express.urlencoded({ extended: true })) | ||
app.use(express.json()) | ||
app.use(expressSession({ | ||
secret: process.env.SECRET, | ||
resave: true, | ||
saveUninitialized: true | ||
})) | ||
app.use(cookieParser()) | ||
|
||
app.listen(process.env.PORT, () => { | ||
console.log(`Server is running at http://localhost:${process.env.PORT}`); | ||
}) | ||
|
||
app.use(express.static(__dirname + '/public')) | ||
|
||
const quranRouter = require('./routes/quran') | ||
const noteRouter = require('./routes/note') | ||
app.use(quranRouter) | ||
app.use('/note', noteRouter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const mongoose = require('mongoose') | ||
|
||
let suraScheema = mongoose.Schema( | ||
{ | ||
sura: String, | ||
ayah: String, | ||
text: String | ||
} | ||
) | ||
|
||
module.exports = mongoose.model('Notes', suraScheema) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const mongoose = require('mongoose') | ||
var mongoosePaginate = require('mongoose-paginate-v2'); | ||
|
||
let suraScheema = mongoose.Schema( | ||
{ | ||
sura: String, | ||
ayah: String, | ||
text: String, | ||
doc_id: String, | ||
primary: String | ||
} | ||
) | ||
suraScheema.plugin(mongoosePaginate); | ||
|
||
module.exports = mongoose.model('Ayah', suraScheema, 'ayah') |
Oops, something went wrong.