Skip to content

Instantly share code, notes, and snippets.

const express = require('express');
const app = express();
const router = express.Router();
const makeMockHandler = (name) => (req, res) => {
const message = `${name} --> ${req.originalUrl}`;
console.log(message);
res.json({ handler: name });
};
@ericmacfa
ericmacfa / index.js
Last active July 5, 2019 15:40
Fastify 1733 -- Lifecycle is not interrupted when onSend executes asynchronously
'use strict';
const fastify = require('fastify')();
const promiseTimeout = ms =>
new Promise(resolve => {
setTimeout(resolve, ms);
});
// This issue occurs with both callback and promise based `onSend` hooks
@ericmacfa
ericmacfa / index.js
Last active July 3, 2019 14:49
fastify-session -- Request handler called even when response.redirect() is called in preHandler
const fastify = require('fastify')();
const fastifyCookie = require('fastify-cookie');
const fastifySession = require('fastify-session');
const MemoryStore = require('memorystore')(fastifySession);
const ms = require('ms');
// region Plugins =============================================================
fastify.register(fastifyCookie);
fastify.register(fastifySession, {
cookieName: 'id',
@ericmacfa
ericmacfa / DemoTestGoogle.js
Created July 23, 2016 00:18
StackOverflowGist_nightwatchjs-how-to-check-if-element-exists-without-creating-an-error-failure-exception
// Example adapted from the examples at http://nightwatchjs.org/guide#writing-tests
module.exports = {
'Navigate to google': function (browser) {
browser.windowMaximize();
browser.url('http://www.google.com');
browser.waitForElementVisible('body', 1000);
},
'Try a junk selector that doesnt exist, using .elements': function (browser) {
// Note that the status is 0