Skip to content

Instantly share code, notes, and snippets.

@HarshithaKP
HarshithaKP / multi-session-type.js
Created December 26, 2019 11:05
An Express demo that shows usage of multiple session types in a single application.
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 November 19, 2019 07:20
Multer file upload with Axios client
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 February 12, 2022 09:19
Demonstration of how user session can be persisted across redirects, with an express server and request client.
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 }}))