Skip to content

Instantly share code, notes, and snippets.

🌴
On vacation

Zaiste zaiste

🌴
On vacation
Block or report user

Report or block zaiste

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
@zaiste
zaiste / secure-rest-api-nodejs-without-jwt.md
Created May 7, 2019
Creating Secure REST APIs in Node.js without JWTs
View secure-rest-api-nodejs-without-jwt.md

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.

View web-frameworks-benchmark-using-wrk.csv
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
View test-szelmostwo-2.js
const Szelmostwo = require('./');
const { ok, json, created } = require('./response');
const { serve, security } = require('./middleware');
const app = new Szelmostwo();
app.get(
'/',
security(),
View test-szelmostwo.js
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';
});
View benchmark-szelmostwo.js
const Szelmostwo = require('./');
const { ok } = require('./response');
const app = new Szelmostwo();
app.get('/', async _ => ok({ hello: 'world' }));
app.listen(3000);
View css-frameworks-by-size.csv
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 Jan 19, 2019
Node.js, PostgreSQL Authentication & Session Management
View nodejs_postgresql_authentication_session_management.md

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 Nov 13, 2018 — forked from seandenigris/.gitignore
Simple script to dump an IMAP folder into eml files
View .gitignore
.password
Downloads/
View gist:7a11b67f41eed62581bf096c00127868
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
@zaiste
zaiste / reasonml-getting-started.org
Last active May 12, 2018
Reason in a nutshell: Getting Started Guide
View reasonml-getting-started.org

Reason in a nutshell: Getting Started Guide

This guide intends to provide a comprehensive, but relatively short introduction to Reason.

Reason is a programming language built on top of OCaml. It provides functional and object-oriented features with type-safety and focus on performance. It was created at Facebook. Its syntax is similar to JavaScript. The intention is to make interoperation with JavaScript and adoption by JavaScript programmers easier. Reason can access both JavaScript and OCaml ecosystems. OCaml was created in 1996. It is a functional programming language with infered types.

The Reason website contains an online playground. It allows to play with the language and see how the generated JavaScript looks like. It can also convert from OCaml to Reason.

You can’t perform that action at this time.