Skip to content

Instantly share code, notes, and snippets.

View paolochiodi's full-sized avatar

Paolo Chiodi paolochiodi

View GitHub Profile
@paolochiodi
paolochiodi / README.md
Created October 24, 2022 14:25
fastify-raw-body bodyLimit reduced test case

To replicate the issue:

  1. Install dependencies with npm install
  2. Run the server with node server.js
  3. Run the client with node client.js

We expect the request to complete successfully as the body reques is within the limit set on the specific route. You will see that the request does not return an error, it just hangs up.

Replacing BODY_KO with BODY_OK in client.js and re-lunching it will show that normal requests do work.

@paolochiodi
paolochiodi / index.js
Created January 28, 2022 14:33
Repro for mercurius-validation nullable types issue
'use strict'
const Fastify = require('fastify')
const mercurius = require('mercurius')
const mercuriusValidation = require('mercurius-validation')
const assert = require('assert')
const app = Fastify()
const schema = `

Keybase proof

I hereby claim:

  • I am paolochiodi on github.
  • I am paolochiodi (https://keybase.io/paolochiodi) on keybase.
  • I have a public key ASA2ltt0YyBXqEwZn1sIYTaMYeyQevUnnBkPs-zRwRzYsAo

To claim this, I am signing this object:

function db (opts) {
const pool = new pg.Pool(config.get('pgdb'))
this.query = function query (...args) {
pool.query(...args)
}
this.withTransaction = function withTransaction (tasks, done) {
const job = {
/* Copyright (c) 2014-2016 Richard Rodger, MIT License */
'use strict'
// Core modules.
var Assert = require('assert')
// Create root instance. Exported as module.
// * `options` (object): instance options as key-value pairs.
@paolochiodi
paolochiodi / get-address.js
Created September 20, 2016 16:33
get ip address for given interface
'use strict';
var os = require('os');
function findIp (ifname) {
var ifaces = os.networkInterfaces()
var ifname = ifname || 'eth0'
var iface = ifaces[ifname].find(function (iface) {
@paolochiodi
paolochiodi / index.js
Created September 7, 2016 08:17
Seneca3 problem with decorate in plugins and chained configuration
'use strict'
var plugin = require('./plugin');
require('seneca')({
tag: 'repl',
log: 'silent',
legacy: { logging: false },
debug: {short_logs:true}
@paolochiodi
paolochiodi / README.md
Last active September 11, 2015 15:39
Example to create importable test suites with lab

This is a possible approach to create a set of tests (child.js) that can be imported into another project (parent.js) and run through it. This kind of approach also allows to pass parameters and options to the initial set of tests (in this case si).

Another possible approach is to just return lab from the child test and have it re-exported by parent (in this case parameteres would need to be added to tests).

Tests are run with lab parent.js.

This has been explored for use in seneca-store-test. Using this approach we can refactore seneca-store-test to directly use experiments and tests (or describe/it in BDD parlance) while still depende on store implementation to provide a correctly configured seneca instance. The added benefits imho are:

@paolochiodi
paolochiodi / leak.js
Created December 24, 2013 06:51
Test resizer for memory leaks
var fs = require('fs');
var resizers = require('../index');
var execute = function(next) {
var Cover = resizers.cover;
var Contain = resizers.contain;
var Crop = resizers.crop;
var inputImage = fs.createReadStream(__dirname + '/test.jpg');
require 'net/http'
require 'json'
auth_uri = URI('https://api.blomming.com/v1/oauth/token')
json_uri = URI('https://api.blomming.com/v1/categories/158/items')
params = {
:grant_type => 'client_credentials',
:client_id => '<CLIENT_ID>',
:client_secret => '<CLIENT_SECRET>'