Skip to content

Instantly share code, notes, and snippets.

View stuart-haas's full-sized avatar

Stuart Haas stuart-haas

View GitHub Profile
@stuart-haas
stuart-haas / asyncRequest.js
Created October 15, 2021 14:22
Express route controller async wrapper
/**
Throw uncaught errors to the next middleware automatically
and avoid having to use try/catch in the controller methods
router.get('/', asyncRequest(controller.index));
with asyncRequest...
index: async(req, res) => {
const data = await Model.findAll();
@stuart-haas
stuart-haas / baby.js
Created May 27, 2022 17:05
Code Baby
const assert = (...args) => {
this.args = args
return {
equals: (arg) => {
console.log(`${this.args.join(' + ')} = ${arg}`)
return this.args
}
}
return this;