Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
@nclabs/rpc-config
Advanced tools
Utilitário para configuração de rotas e cache em microserviços. Utilido especificamente para projetos nclabs
Utilitário para configuração de rotas e cache em microserviços. Utilido especificamente para projetos nclabs
npm i @nclabs/rpc-config
// ./config/configuration.ts
export default () => ({
service: process.env.<SERVICE_NAME> || <service_name>,
redis: {
host: process.env.REDIS_HOST || 'localhost',
port: parseInt(process.env.REDIS_PORT, 10) || 6379,
password: process.env.REDIS_PASSWORD || '',
},
cache: {
prefix: process.env.CACHE_PREFIX || 'API-CACHE',
ttl: parseInt(process.env.CACHE_TTL, 10) || 600,
logCacheHit: process.env.CACHE_HIT_LOG === 'true',
},
...
});
// app.module.ts
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { APP_INTERCEPTOR } from '@nestjs/core';
import { CacherInterceptor, RpcConfigModule } from '@nclabs/rpc-config';
import configuration from './config/configuration';
@Module({
imports: [
// Config - importante para o cache que a configuração seja global
ConfigModule.forRoot({
cache: true,
isGlobal: true,
load: [configuration],
}),
// RPC Config Module
RpcConfigModule.forRoot(),
],
...
providers: [
...
// Cache Manager Interceptor
{
provide: APP_INTERCEPTOR,
useClass: CacherInterceptor,
},
],
})
export class AppModule {}
// app.controller.ts
import { Action, Event, Rest } from '@nclabs/rpc-config';
import configuration from './config/configuration';
...
/**
*
* REST ACTION
*/
@Rest({
rpc: config.service,
rest: {
methods: ['GET', 'POST'],
path: '/user-credential/:id',
},
cache: {
keys: ['#headers.authorization', '#params.username'],
ttl: 200,
},
})
userCredential(@Payload() params: { username: string }): Observable<UserCredential> {
return this.appService.getUserCredential();
}
...
/**
*
* RPC ACTION
*/
@Action({
rpc: config.service,
name: 'get-user-credential',
cache: {
keys: ['#params.apiKey'],
},
})
getTokenFromKey(@Payload() params: { apiKey: string }): Obserable<UserCredential> {
console.log('params', params);
return this.appService.getUserCredential();
}
...
/**
*
* RPC EVENT
*/
@Event({
rpc: config.service,
name: 'user-changed',
})
eventTeste(@Payload() params: UserPayload /* @Ctx() context: NatsContext */): void {
// do something
return;
}
FAQs
Utilitário NestJS para configuração de rotas e cache em microserviços. Utilido especificamente para projetos nclabs
The npm package @nclabs/rpc-config receives a total of 0 weekly downloads. As such, @nclabs/rpc-config popularity was classified as not popular.
We found that @nclabs/rpc-config demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.