mr365-utils
v1.0.0
Published
Small, generic Node/Express helpers.
Readme
mr365-utils
Small, generic Node/Express helpers.
Install
npm install mr365-utilsUsage
const { corsAndBodyParser, coerceBoolean } = require('mr365-utils');
const { createCacheService } = require('mr365-utils/cache');What's in it
Express — corsOptions, allowAllOrigins, corsAndBodyParser(app), isLocal(req),
expressIsLocal, safeResponseMiddleware
Types & strings — isBuffer, tp, lowercase, coerceBoolean, fixObjectValueTypes,
urlSafeString, isFreeMail
Time — dateToMsISOString, adjustedTimeFromNow, tsToTrunc, truncToTS
Random — randomInt, s4, shuffle, rint. All CSPRNG-backed.
Cache — createCacheService, also available as require('mr365-utils/cache'). In-memory
via node-cache, with an optional Redis backend and optional distributed invalidation.
Scope
Generic helpers only. Anything application-specific belongs in the application, not here.
Test
npm test