Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var express = require('express')
var session = require('express-session')
var grant = require('grant-express')
var request = require('request-compose').client
var jwt = require('./jwt')
express()
.use(session({name: 'grant', secret: 'grant', saveUninitialized: true, resave: true}))
.use(grant(require('./config.json')))
.get('/hello', async (req, res) => {
var {body} = await request({
url: 'https://graph.facebook.com/v2.12/me',
headers: {authorization: `Bearer ${req.session.grant.response.access_token}`}
})
// remove the session data
req.session.destroy(() => {
// remove the cookie
res.clearCookie('grant')
it('extend', async () => {
var {body} = await request({url: 'http://localhost:5000/qstext'})
t.deepStrictEqual(body, {nested: {querystring: 'true'}})
var {body} = await compose.client({url: 'http://localhost:5000/qstext'})
t.equal(body, 'nested%5Bquerystring%5D=true')
})
var request = require('request-compose').client
;(async () => {
try {
var {res, body} = await request({
url: 'https://api.github.com/users/simov',
headers: {
'user-agent': 'request-compose'
}
})
console.log(res.statusCode, res.statusMessage)
console.log(res.headers['x-ratelimit-remaining'])
console.log(body)
}
catch (err) {
console.error(err)
}
var compose = require('request-compose')
var request = compose.client
var pipe = ({auth, address}) => compose(
_ => request({
url: 'https://maps.googleapis.com/maps/api/geocode/json',
qs: {key: auth.google, address},
}),
({body: {results: [{geometry: {location}}]}}) => request({
url: `https://api.darksky.net/forecast/${auth.darksky}/${location.lat},${location.lng}`,
qs: {exclude: 'minutely,hourly,daily,alerts,flags'},
}),
({body: {currently: {icon}}}) => ({
'clear-day': 'sunny',
'clear-night': 'crescent_moon',
'rain': 'rain_cloud',
'snow': 'snow_cloud',
'sleet': 'snowflake',