@umukorog-tickets/common
v1.1.29
Published
--- @umukorog-tickets/common is a javascript package for managing communications within microservice.
Downloads
25
Readme
@umukorog-tickets/common
@umukorog-tickets/common is a javascript package for managing communications within microservice.
It contains functionalities for NATS server management, authentication and Error handling. This NPM module provides developers with a robust toolkit for managing NATS servers seamlessly, implementing secure authentication strategies, and ensuring resilient error handling. Its flexibility and adaptability make it an invaluable asset for projects requiring reliable and secure communication in distributed systems.
Key Features
- NATS Server Management
- Provides seamless integration with Node.js projects for simplified server management
- Authentication Module
- Includes authentication to ensure secure commmunications between services.
- Error Handling
- Customizable error responses to ensure grateful degradation in case of communication failures
Installing
For the latest stable version, run:
npm
npm install @umukorog-tickets/common
Usuage
import express, { Request, Response } from 'express';
import { NotFoundError, requireAuth, validateRequest } from '@umukorog-tickets/common';
import { Ticket } from '../models/ticket';
const router = express.Router();
router.post(
'/api/route',
requireAuth,
validateRequest,
async (req: Request, res: Response) => {
const { ticketId } = req.body;
const ticket = await Ticket.findById(ticketId);
if (!ticket) {
throw new NotFoundError();
}
res.send(ticket);
}
);
export { router as newOrderRouter };