
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
Implemented JSON RPC specification
npm i --save asc-rpc
Import module RpcModule from asc-rpc, example
JsonRpcModule.forRoot({
path: '/rpc', // path to RPC
})
Create simple RPC handler
create RPC handler
import { RpcId, RpcPayload, RpcVersion, RpcMethod, IRpcHandler, RpcHandler } from 'asc-rpc';
@RpcHandler({
method: 'test',
})
export class TestHandler implements IRpcHandler<Payload> {
public async invoke(
@RpcPayload() payload: Payload,
@RpcVersion() version: string,
@RpcId() id: number | string,
@RpcMethod() method: string
) {
return payload;
}
}
Add TestHandler to providers array
Every request to RPC is POST method and response status = 200
Test with curl
curl -X POST "http://localhost:3000/rpc" -H "accept: application/json" -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "test", "id": 2}'
Create multiple RPC handler in one class
Create RPC class handler
import { RpcId, RpcPayload, RpcVersion, RpcMethod, RpcMethodHandler, RpcHandler } from 'asc-rpc';
@RpcHandler({
method: 'contact',
})
export class ContactHandler {
@RpcMethodHandler('add')
public async add(
@RpcPayload() payload: Payload,
@RpcVersion() version: string,
@RpcId() id: number | string,
@RpcMethod() method: string
) {
return payload;
}
@RpcMethodHandler('delete')
public async delete(
@RpcPayload() payload: Payload,
@RpcVersion() version: string,
@RpcId() id: number | string,
@RpcMethod() method: string
) {
return payload;
}
}
Add ContactHandler to providers array
Every request to RPC is POST method and response status = 200
Test with curl contact.add
curl -X POST "http://localhost:3000/rpc" -H "accept: application/json" -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "contact.add", "id": 2}'
Test with curl contact.delete
curl -X POST "http://localhost:3000/rpc" -H "accept: application/json" -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "contact.delete", "id": 2}'
| field | decorator | description | required | other |
|---|---|---|---|---|
params | @RpcPayload() | get payload ( params ) | false | use pipes... |
jsonrpc | @RpcVersion() | get rpc version | true | use pipes... |
method | @RpcMethod() | get rpc version | true | use pipes... |
id | @RpcId() | get client operation id | false | if not send - response not send, RPC notification. use pipes... |
FAQs
JSON RPC module for NestJS framework
The npm package asc-rpc receives a total of 333 weekly downloads. As such, asc-rpc popularity was classified as not popular.
We found that asc-rpc demonstrated a not healthy version release cadence and project activity because the last version was released 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
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.