
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@nl-framework/microservices
Advanced tools
Microservices module for nl-framework with Dapr integration, NestJS-style message patterns, and pub/sub abstractions.
Microservices module for nl-framework providing NestJS-style message patterns, event-driven architecture, and Dapr integration.
@MessagePattern and @EventPattern to handle incoming messagesemit() (fire-and-forget) or send requests with send() (request/response)@nl-framework/logger for structured logging@UseGuards(), @UseInterceptors(), @UsePipes(), and @UseFilters() from @nl-framework/core, just like HTTP and GraphQL controllersbun add @nl-framework/microservices
Add to your config/default.yaml:
microservices:
dapr:
httpPort: 3500
grpcPort: 50001
componentsPath: ./dapr/components
pubsub:
name: redis-pubsub
import { Controller, Injectable } from '@nl-framework/core';
import { MessagePattern, EventPattern } from '@nl-framework/microservices';
@Controller()
@Injectable()
export class OrdersController {
@MessagePattern('order.created')
handleOrderCreated(context: MessageContext) {
console.log('Order created:', context.data);
return { status: 'processed' };
}
@EventPattern({ cmd: 'notify' })
handleNotification(context: MessageContext) {
console.log('Notification:', context.data);
}
}
Decorator Tip: Import
@UseGuards(),@UseInterceptors(),@UsePipes(), and@UseFilters()from@nl-framework/coreto apply the same guard/interceptor/pipe/filter semantics to message handlers that you already use in HTTP or GraphQL controllers.
import { Module } from '@nl-framework/core';
import { createMicroservicesModule } from '@nl-framework/microservices';
import { OrdersController } from './orders.controller';
@Module({
imports: [
createMicroservicesModule({
controllers: [OrdersController],
}),
],
controllers: [OrdersController],
})
export class AppModule {}
import { MicroserviceClient } from '@nl-framework/microservices';
@Injectable()
export class OrdersService {
constructor(private readonly client: MicroserviceClient) {}
async createOrder(data: unknown) {
// Fire-and-forget event
await this.client.emit('order.created', { orderId: 123, ...data });
// Request/response (coming soon)
// const result = await this.client.send('process.order', data);
}
}
@MessagePatternDecorator(pattern)Marks a method as a message handler for request/response patterns.
@MessagePatternDecorator('user.get')
async getUser(context: MessageContext) {
return { id: 1, name: 'John' };
}
@EventPattern(pattern)Marks a method as an event handler (fire-and-forget).
@EventPattern('user.created')
handleUserCreated(context: MessageContext) {
console.log('New user:', context.data);
}
emit(pattern, data)Publishes a fire-and-forget event.
await client.emit('order.created', { orderId: 123 });
send(pattern, data)Sends a request and awaits a response (coming soon).
const result = await client.send('process.payment', { amount: 100 });
Microservice handlers use the shared @UseFilters() decorator and the MicroserviceExceptionFilter interface to handle
errors consistently with HTTP and GraphQL.
import { Controller, Injectable, UseFilters } from '@nl-framework/core';
import {
MessagePattern,
MicroserviceExceptionFilter,
MicroserviceExceptionContext,
} from '@nl-framework/microservices';
@Injectable()
class LoggingFilter implements MicroserviceExceptionFilter {
catch(exception: Error, context: MicroserviceExceptionContext) {
context.logger?.error({ pattern: context.pattern, exception });
return { ok: false };
}
}
@Controller()
@UseFilters(LoggingFilter)
export class OrdersConsumer {
@MessagePattern('orders.create')
async create(order: OrderDto) {
throw new Error('Not implemented');
}
}
Method-level filters run before class-level filters. Return a value from catch() to override the handler response; return
undefined to continue to the next filter.
import { registerMicroserviceExceptionFilter } from '@nl-framework/microservices';
registerMicroserviceExceptionFilter(new LoggingFilter());
Use registerMicroserviceExceptionFilter() or registerMicroserviceExceptionFilters() during bootstrap to apply filters
to every handler. The dispatcher resolves tokens through dependency injection if available, then instantiates classes or
uses provided instances.
Create dapr/components/redis-pubsub.yaml:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: redis-pubsub
spec:
type: pubsub.redis
version: v1
metadata:
- name: redisHost
value: localhost:6379
dapr run --app-id my-service --app-port 3000 --dapr-http-port 3500 -- bun run start
import { DaprTransport } from '@nl-framework/microservices';
const transport = new DaprTransport({
daprHost: 'localhost',
daprHttpPort: 3500,
pubsubName: 'redis-pubsub',
logger: myLogger,
});
Implement the Transport interface:
import type { Transport, MessagePattern } from '@nl-framework/microservices';
export class CustomTransport implements Transport {
async connect(): Promise<void> {
// Initialize connection
}
async close(): Promise<void> {
// Cleanup
}
async emit(pattern: MessagePattern, data: unknown): Promise<void> {
// Publish event
}
async send<TResult>(pattern: MessagePattern, data: unknown): Promise<TResult> {
// Send request, await response
}
}
@nl-framework/http for hybrid servicesMIT
FAQs
Microservices module for nl-framework with Dapr integration, NestJS-style message patterns, and pub/sub abstractions.
We found that @nl-framework/microservices demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.