Packages for node.js and npm.
javascript
+ ██╗
+ ██████╗ ███████╗ █████═████╗ ██████╗ ██████╗██║ ██╗
+██╔═══██╗██╔═════╝██╔══██╔══██╗██╔═══██╗██╔════╝██║ ██╔╝
+████████║╚██████╗ ██║ ██║ ██║██║ ██║██║ ██████╔╝
+██╔═════╝ ╚════██╗██║ ██║ ██║██║ ██║██║ ██╔══██╗
+╚███████╗███████╔╝██║ ██║ ██║╚██████╔╝╚██████╗██║ ╚██╗
+ ╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝
Esmock is a node.js module-mocking package for unit-tests. It was created by me so that Iconic Engine could use native ESM modules inside unit tests,
It is a super-high-quality package with extensive unit-tests for multiple test-runners and environments. Its function requires scripted module resolutions that are almost impractically complex to resolve.
I wrote this package. Iconic Engine used it to unit-test many node.js applications.
javascript
mmReql is a mock RethinkDB database package supporting advanced RethinkDB queries and features like changefeeds. It was used by many RethinkDB-using services for unit-testing and offline-development.
const dbRoomMembershipResolve = async (r, db, membershipId) => r
.db(db)
.table(tableRoomMemberships)
.get(membershipId)
.merge(row => ({
user_target: r.db(db).table(tableUsers).get(row('user_id'))
.pluck('id', 'numeric_id', 'display_name', 'avatar_id')
.default(null),
user_sender: r.db(db).table(tableUsers).get(row('user_sender_id'))
.pluck('id', 'numeric_id', 'display_name', 'avatar_id')
.default(null),
room: r.db(db).table(tableRooms).get(row('room_id'))
.pluck('id', 'numeric_id', 'display_name', 'group_type', 'app_version')
.default(null)
})).run()
I created this mock database package. It was used for unit-testing RethinkDB-using services.
When Iconic Engine ceased, I requested permission to own the package and publish it on the internet where it is now available on github and npm.
javascript
Clak returns international content from csv files. It is ~100 LOC with no dependencies.
clak(access_denied, langs, ['ja-JP']) // 'あなたが入れない駄目です'
clak(access_denied, langs, ['en-US']) // 'access denied'
I wrote this package. It allowed services to use CSV-translation files without writing strange code or introducing un-wanted dependency trees.
HTML, Javascript
Email templates in this package were used as notification emails, verification emails, invitation emails and more. The project's gitlab "deployment" pipeline served template HTML from a bucket and everyone could see the templates in a browser (cool, imo).
I wrote this package and the initial set of templates provided. I updated services inside Iconic Engine's cluster to use the template emails.
iconicdam.registration.en-US.html
iconicdam.reset-password-requested.en-US.html
iconicdam.studio-invitation.en-US.html
vasoo.registration-update-birthday.de-DE.html
vasoo.registration-update-birthday.en-US.html
vasoo.registration-update-birthday.es-ES.html
vasoo.registration-update-birthday.hi-IN.html
vasoo.registration.de-DE.html
vasoo.registration.en-US.html
vasoo.registration.es-ES.html
vasoo.registration.hi-IN.html
vasoo.reset-password-requested.de-DE.html
vasoo.reset-password-requested.en-US.html
vasoo.reset-password-requested.es-ES.html
vasoo.reset-password-requested.hi-IN.html
javascript
sse-subscription
was an internal package "plugin" for serving GraphQL subscription data using Server Sent Events
(or "SSE"). Existing GraphQL SSE packages did and (do currently) require clients to open a connection using two requests (first request initializes a session and second request begins the stream) but this package contained a solution allowing it to support a single-request.
sseSubscription(graphql, app, apolloServer, executableSchema, {
staticQueryMap,
onContext: authContextGet,
onConnective: async (ctx, isConnecting) => {
const { aud, sub } = (ctx.authDecoded || {})
const db = aud && dbNameFromAppClientId(aud)
if (sub) isConnecting
? await dbPresenceSetStateONLINE(r, db, sub)
: await dbPresenceSetStateOFFLINE(r, db, sub)
}
})
I wrote this plugin experimenting with Apollo GraphQL to determine its best operation.
Having our own Apollo-decoupled SSE package spared us from churn, where major versions of Apollo GraphQL constantly changed and discontinued stream plugins.
javascript
Slim-error exported various Error constructors that could be used interchangably with both Apollo GraphQL and REST services. It could integrate with analytics and logging utilities and stream error details into those.
import {
ErrorClient
} from 'slim-error'
throw new ErrorClient(
'Client error \(〇_o)/. Bad Request.' )
// CLIENT_ERROR @Error {
// error_type: 'CLIENT_ERROR',
// status_code: 400,
// message: 'Client error \(〇_o)/. Bad Request.'
// }
I wrote this package to replace problematic error scripts used by legacy Iconic Engine services.
javascript
This was a health-checking koa middleware used with Kubernetes' health-checking system. Its JSON-responses followed IETF specifications.
const healthFnHealthProxy = koahealth(healthCheckTypeHEALTHPROXYPING, {
// onCheck is a checking function,
// called each time checkHealthFn() is called,
//
// if `truthy` is returned,
// result is `{ ok: true }`
// else
// result is `{ ok: false }`
onCheck: async () => reqHealthStatusPing(),
errorMsg: 'Could not reach health proxy.',
onCheckPass: (details, healthRes, timeElapsed) => ({
...details,
measurement: 'responseTime',
value: Math.round(timeElapsed),
unit: 'ms'
}),
timeoutfail: 60000, // 1 min
timeoutwarn: 5000, // 5 sec
onCheckFail: (details, res, err) => {
if (err) log.warn(err)
return details
},
// third param is a runtime error, if one occurred
onCheckFailTimeout: (details, timeout) => ({
...details,
error: `Component did not respond in a reasonable time ${timeout}`,
measurement: 'responseTime',
unit: 'ms',
report: true
})
})
I wrote this package to generate health-checking reporting of database and service availability and to restart and stop host applications under certain failure conditions.