Skip to content

Instantly share code, notes, and snippets.

😇
Living the JS life

Vladimir de Turckheim vdeturckheim

😇
Living the JS life
Block or report user

Report or block vdeturckheim

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View async_storage.md

Most Node.js framework requires to pass an object representing the current HTTP request through every layers of the application. This is most visible in Expressjs-based applications:

// TODO middleware example

Other frameworks, will create an wrapping object around the raw Node.js request:

// TODO hapi link

But at the end of the day, developers end up passing bloated objects representing the requests through their codebase:

View README.md

MongoDB need to be installed and running on localhost (otherwise, edit the value of MONGO_URL in server.js).

For Sqreen to work, create a new application on https://my.sqreen.io and add the sqreen.json file to the root of the project.

Start the server with node server.js

Perform an attack with:

$ curl -X POST \
  http://localhost:3000/login \
View beyond_domains.md

Beyond Domains

Goal

The goal of this document is to analysis the content of the Domain Module Postmortem to define the need for either:

  • a new internal API in Node.js core (SOLUTION 1)
  • a solution to update domain API to have TSC reconsider its deprecation status (SOLUTION 2)
  • an external API to replace domain only in userland (SOLUTION 3)
View keybase.md

Keybase proof

I hereby claim:

  • I am vdeturckheim on github.
  • I am ecares (https://keybase.io/ecares) on keybase.
  • I have a public key ASCYrvfvzp9hRv0VSx6JA_pAUKwnqVsiHgwUuRi-V-HMvQo

To claim this, I am signing this object:

View test.js
'use strict';
const Code = require('code');
const expect = Code.expect;
const Lab = require('lab');
const lab = module.exports.exports.lab = Lab.script();
const after = lab.after;
const before = lab.before;
const describe = lab.describe;
const it = lab.it;
View app.post.js
app.post('/posts', Celebrate.celebrate(
{
body: Joi.object().keys({
title: Joi.string().required(),
content: Joi.string().required()
})
}
),
(req, res, next) => {
View server.js
'use strict';
const Express = require('express');
const BP = require('body-parser');
const DB = require('./db.js');
const app = Express();
app.use(BP.json());
View db.js
const DB_NAME = 'tests-express-sqlite';
const Fs = require('fs');
const Path = require('path');
const Sqlite = require('sqlite3');
try {
Fs.unlinkSync(`./${DB_NAME}`);
}
catch (_ign) {}
View init.sql
CREATE TABLE POSTS(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
TITLE TEXT NOT NULL,
CONTENT TEXT
);
INSERT INTO POSTS (TITLE, CONTENT)
VALUES ('hello world', 'hello');
INSERT INTO POSTS (TITLE, CONTENT)
View switch-with-over-128-cases-2.js
function exec(arg) {
switch (arg) {
case 1: break;
case 2: break;
...
case 128: break;
case 129: break;
}
}
You can’t perform that action at this time.