-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from ChaxuGarg/master
Pull request for requestToken endpoint
- Loading branch information
Showing
8 changed files
with
197 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,9 @@ | ||
import redis from 'redis'; | ||
|
||
const rtokens = redis.createClient(); | ||
|
||
rtokens.on('error', (err) => { | ||
console.log(err); | ||
}); | ||
|
||
export default rtokens; |
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
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
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,35 @@ | ||
import express from 'express'; | ||
import util from 'util'; | ||
import rtoken from '../data/resourceToken'; | ||
import { makeid } from '../utils/utils'; | ||
|
||
const router = express.Router(); | ||
|
||
// api route to check whether current requestToken exists or not | ||
|
||
router.post('/checkFunction', async (req, res) => { | ||
let { requestToken } = req.body; | ||
let exists = 1; | ||
rtoken.exists = util.promisify(rtoken.exists); | ||
while (exists) { | ||
// eslint-disable-next-line no-await-in-loop | ||
exists = await rtoken.exists(requestToken.toString()); | ||
requestToken = makeid(64, true); | ||
console.log(exists); | ||
} | ||
res.send(requestToken); | ||
}); | ||
|
||
// route to check all the data stored in redis | ||
|
||
router.get('/rediData', (req, res) => { | ||
rtoken.keys('*', (err, keys) => { | ||
// eslint-disable-next-line array-callback-return | ||
keys.map((key) => { | ||
console.log(key); | ||
console.log(rtoken.hmget(key, ['cId', 'uId'])); | ||
}); | ||
}); | ||
res.send(200); | ||
}); | ||
export default router; |
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