@qiwi/cookiemonster
v0.1.0
Published
Stateless fake API based on cookie processing
Downloads
7
Readme
qookiemonster
Stateless fake API based on cookie processing
Usage
On server side:
//...
import {cookiemonster} from '@qiwi/cookiemonster'
const app = express()
app.use(cookieParser())
app.use(bodyParser.json())
app.use(cookiemonster())
app.listen(8080)
On client:
import {formatScenario} from '@qiwi/cookiemonster'
const data = formatScenario({
steps: [
{res: {code: 200, body: {foo: 'bar'}}}
]
})
document.cookie = `Cookiemonster=${data}`
const result = await fetch('http://localhost:8080', {credentials: 'include'})
const json = await result.json() // {foo: 'bar'}