Skip to content

Instantly share code, notes, and snippets.

@HarshithaKP
HarshithaKP / multi-session-type.js
Created Dec 26, 2019
An Express demo that shows usage of multiple session types in a single application.
View multi-session-type.js
var express = require('express')
var app = express()
var session = require('express-session')
const port = 8000
// session for local clients
var s1 = session({ name: 'one', secret: 'abc'})
// session for remote clients
var s2 = session({ name: 'two', secret: 'def'})
@HarshithaKP
HarshithaKP / AxiosClient.js
Created Nov 19, 2019
Multer file upload with Axios client
View AxiosClient.js
var axios = require('axios')
var FormData = require('form-data')
var fs = require('fs')
const form = new FormData()
const url = 'http://localhost:8000'
//Read the file from disc
form.append ('file',fs.createReadStream('./test.js'))
axios.post (url, form, { headers: form.getHeaders()}
@HarshithaKP
HarshithaKP / SessionPersistence.js
Last active Apr 17, 2021
Demonstration of how user session can be persisted across redirects, with an express server and request client.
View SessionPersistence.js
var express = require('express')
var session = require('express-session')
var app = express()
var r = require('request')
// By default cookies are disabled, switch it on
var request = r.defaults( { jar:true } )
app.use(session({ secret: 'keyboard cat',saveUninitialized : false, resave : false, cookie: { maxAge: 60000 }}))