Skip to content

Instantly share code, notes, and snippets.

View zaiste's full-sized avatar
🌀
Loading...

Jakub Neander zaiste

🌀
Loading...
View GitHub Profile
@zaiste
zaiste / app.js
Created March 4, 2020 16:21
Fun with Pure Engine
const { compile } = require('pure-engine')
const escape = require('escape-html')
const fs = require('fs-extra');
async function example() {
const content = await fs.readFile('./index.html');
const { template } = await compile(content.toString())
console.log(template({ foo: 'bar' }, escape))
}
@zaiste
zaiste / secure-rest-api-nodejs-without-jwt.md
Created May 7, 2019 12:23
Creating Secure REST APIs in Node.js without JWTs

Creating Secure REST APIs in Node.js without JWTs

Before we go on creating an actual RESTful API, let's address the elephant in the room: how to make an HTTP endpoint sufficiently secure in Node.js ?

I say sufficiently because, the topic of security is broad and constantly evolves. This article is a response to other Node.js articles I've seen that contain security mistakes. It may not be perfect, either, but is hopefully a good evolution on the topic.

Check the full article.

Version URL Req/s Avg Req/s Max Req/s Total Latency Avg Latency Max
Node.js Bare 11.14.0 2180 3410 54257 8.49 1.84 6.49
Fastify 2.3.0 2170 5240 54068 8.46 1.85 5.63
Szelmostwo (Huncwot's Core) 0.5.1 3440 5460 85482 8.80 1.17 3.55
Huncwot 0.40.0 https://huncwot.org/ 3430 6020 85167 8.77 1.17 3.48
uWebSockets 15.10.0 6840 7180 170266 19.97 0.58 1.53
Trek Router 0.0.1 1760 3120 43777 6.22 2.28 6.81
Kemal 3750 30940 93217 11.82 1.07 2.07
Turbo HTTP 0.3.2 3220 5700 80123 9.70 1.25 3.46
const Szelmostwo = require('./');
const { ok, json, created } = require('./response');
const { serve, security } = require('./middleware');
const app = new Szelmostwo();
app.get(
'/',
security(),
const Szelmostwo = require('./');
const { ok, json, created } = require('./response');
const app = new Szelmostwo();
app.get('/', async ({ params }) => `Hello, uWS -> ${JSON.stringify(params)}`);
app.get('/throw', async ({ params }) => {
//
throw 'Bajlango';
});
const Szelmostwo = require('./');
const { ok } = require('./response');
const app = new Szelmostwo();
app.get('/', async _ => ok({ hello: 'world' }));
app.listen(3000);
@zaiste
zaiste / css-frameworks-by-size.csv
Created March 5, 2019 18:14
CSS Frameworks by Size
Name Version Size (minified) Size (gzipped) URL
Bootstrap v4.3.1 152 KB 20.96 KB https://getbootstrap.com/
Bootstrap v3.4.1 119 KB 18.47 KB https://getbootstrap.com/docs/3.4/css/
Bulma v0.7.4 177 KB 24 KB https://bulma.io/
Foundation v6.4.3 118 KB 22 KB http://foundation.zurb.com/
Foundation v3.0 64 KB 12 KB http://foundation.zurb.com/
Materialize v3.0 90 KB 18 KB http://materializecss.com/
Material Design Lite v1.3.0 137 KB 21 KB https://getmdl.io/
Milligram v1.3.0 8 KB 2 KB https://milligram.github.io/
mini.css v2.1 36 KB 7 KB https://chalarangelo.github.io/mini.css/
@zaiste
zaiste / nodejs_postgresql_authentication_session_management.md
Last active January 19, 2019 16:43
Node.js, PostgreSQL Authentication & Session Management

Node.js, PostgreSQL Authentication & Session Management

The following flow is implemented in Huncwot - Macro framework for monolithic JavaScript applications, with batteries included.

Setup

Register/Signup

login/signin corresponds to a create method (a HTTP POST action) for Person entity.

@zaiste
zaiste / .gitignore
Created November 13, 2018 14:05 — forked from seandenigris/.gitignore
Simple script to dump an IMAP folder into eml files
.password
Downloads/
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
string-match("^/tmp_mnt/" nil)
abbreviate-file-name(nil)
#f(compiled-function (file name) "Look up the directory hierarchy from FILE for a directory containing NAME.\nStop at the first parent directory containing a file NAME,\nand return the directory. Return nil if not found.\nInstead of a string, NAME can also be a predicate taking one argument\n(a directory) and returning a non-nil value if that directory is the one for\nwhich we're looking." #<bytecode 0x43bbfe51>)(nil ".git")
funcall(#f(compiled-function (file name) "Look up the directory hierarchy from FILE for a directory containing NAME.\nStop at the first parent directory containing a file NAME,\nand return the directory. Return nil if not found.\nInstead of a string, NAME can also be a predicate taking one argument\n(a directory) and returning a non-nil value if that directory is the one for\nwhich we're looking." #<bytecode 0x43bbfe51>) nil ".git")
(if (file-remote-p defaul