diff --git a/examples/memory.js b/examples/memory.js new file mode 100644 index 0000000..b826618 --- /dev/null +++ b/examples/memory.js @@ -0,0 +1,25 @@ +'use strict' + +const Fastify = require('fastify') +const fastifySession = require('..') +const fastifyCookie = require('@fastify/cookie') + +const fastify = Fastify() + +fastify.register(fastifyCookie, {}) +fastify.register(fastifySession, { + secret: 'cNaoPYAwF60HZJzkcNaoPYAwF60HZJzk', + cookie: { secure: false } +}) + +fastify.get('/', (request, reply) => { + reply + .send(request.cookies.sessionId) +}) + +const response = fastify.inject('/') +response.then(v => console.log(` + +autocannon -H "Cookie=${decodeURIComponent(v.headers['set-cookie'])}" http://127.0.0.1:3000`)) + +fastify.listen({ port: 3000 })