
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@redhare/context
Advanced tools
In NestJS we need a context which can be created for every request. This context can contains some information we need for any place can be access.
In NestJS we need a context which can be created for every request. This context can contains some information we need for any place can be access.
Since AsyncLocalStorage is used internally, the required Node.js version is >=14.15.2 that includes significant fixes.
yarn add '@infra-node-kit/context'
first you need use the infraContextMiddleware first, in middleware will create context and add requestId on context.
import { infraContextMiddleware } from '@infra-node-kit/context';
const app = await NestFactory(AppModule);
...
app.use(infraContextMiddleware());
await app.listen(3000);
In you controller, service or any other place can import InfraRequestContext to get the context.
import { InfraRequestContext } from '@infra-node-kit/context'
@Controller('')
export class MyController {
@Get()
test(): string {
const ctx: InfraRequestContext = InfraRequestContext.get()
return ctx.requestId
}
}
options.requestIdKey default value is x-request-id, it define the key name of the response header which contain requestId.options.upstreamRequestIdKey default value is x-request-id, it define the key name of the request header which contain requestId, if request has this header, the project will reuse this value.InfraRequestContextinfraRequestContext = InfraRequestContext.get()
infraRequestContext.requestId is a uuid for every request which first get from request[options.requestIdKey], if not exist, will generate a new UUID. This id will also add into http response headers, header key name is decide by options.requestIdKey
infraRequestContext.userInfo reserved for google login save userInfo
infraRequestContext.userInfoEncrypt reserved for google login save userInfo
infraRequestContext.extra reserved for user can save anything you need
FAQs
In NestJS we need a context which can be created for every request. This context can contains some information we need for any place can be access.
We found that @redhare/context demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.