sidewinder
node-redlock
sidewinder | node-redlock | |
---|---|---|
8 | 2 | |
55 | 1,729 | |
- | - | |
5.1 | 3.7 | |
9 months ago | 3 months ago | |
TypeScript | TypeScript | |
GNU General Public License v3.0 or later | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
sidewinder
- TypeBox: High Performance Runtime Type Checking
- Typescript monorepo with component library help!
- Type Safe Micro Services for Node
- Best HTTP-framework with TypeScript?
- JavaScript Web Service Framework for Microservice Architectures
-
Sidewinder: Type Safe Web Services for Node
trpc is to zod, as sidewinder is to typebox
node-redlock
-
Build an Idempotent API in Node.js with Redis
async function create(req, res) { let lock; try { // Try to acquire the lock lock = await service.urlService.acquireLock( "URL:CREATE:ExclusiveLock", 100 ); const { longURL } = req.body; // Check if the mapping already exists const mapping = await service.urlService.findByLongURL(longURL); if (mapping) { return res.status(HTTP_STATUS_CODES.SUCCESS).json({ status: true, message: "Short slug created successfully", data: { slug: mapping.slug }, }); } // New long URL, generate a new and unique slug const slug = service.urlService.generateNewSlug(); // save short URL <> long URL mapping to the database await service.urlService.saveToDB(slug, longURL); // Return the newly generated short slug return res.status(HTTP_STATUS_CODES.SUCCESS).json({ status: true, message: "Short slug created successfully", data: { slug }, }); } catch (err) { return res.status(HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR).json({ status: false, message: "Could not create short slug", error: err, }); } finally { /** * Manually release the lock when the operation is complete * * NOTE: Redlock's release method is not a no-op, it throws an error if you try to release an already expired lock ([more here](https://github.com/mike-marcacci/node-redlock/issues/168#issuecomment-1165700540)). Setting a small TTL usually triggers this unexpected behavior. * As a workaround, we're ignoring the errors from lock.release() */ if (lock) await lock.release().catch(() => {}); } }
-
Advanced caching mechanisms using distributed locks and async pub/sub systems.
Example: The following example uses Node.js npm module Redlock, which implements Redlock. Redlock is available as a package in many languages.
What are some alternatives?
typeconv - Convert between JSON Schema, TypeScript, GraphQL, Open API and SureType
express-mongodb-rest-api-boilerplate - A boilerplate for Node.js apps / Rest API / Authentication from scratch - express, mongodb (mongoose). Typescript
api - Promise and RxJS APIs around Polkadot and Substrate based chains via RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata.
Conveyor MQ - A fast, robust and extensible distributed task/job queue for Node.js, powered by Redis.
hammer - Build Tool for Browser and Node Applications
zod - TypeScript-first schema validation with static type inference
typebox - Json Schema Type Builder with Static Type Resolution for TypeScript
fastify-auth - Run multiple auth functions in Fastify
Ts.ED - :triangular_ruler: Ts.ED is a Node.js and TypeScript framework on top of Express to write your application with TypeScript (or ES6). It provides a lot of decorators and guideline to make your code more readable and less error-prone. ⭐️ Star to support our work!