
Research
Security News
Malicious npm Package Wipes Codebases with Remote Trigger
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
@tsed/async-hook-context
Advanced tools
Add Async Hook context support in Ts.ED.
This package will be removed in v7 and integrated directly in
@tsed/di
.
Ts.ED provide an injectable [RequestContext] to get all request and response information during a request. But, you have to inject the context from your controller and forward context instance manually to the service.
@Injectable()
export class CustomRepository {
async findById(id: string, ctx: PlatformContext) {
ctx.logger.info("Where are in the repository");
return {
id,
headers: this.$ctx?.request.headers
};
}
}
@Controller("/async-hooks")
export class AsyncHookCtrl {
@Inject()
repository: CustomRepository;
@Get("/:id")
async get(@PathParams("id") id: string, @Context() ctx: PlatformContext) {
return this.repository.findById(id, ctx);
}
}
With this package, you can inject directly the PlatformContext in the service without injecting it in the controller:
@Injectable()
export class CustomRepository {
@InjectContext()
$ctx?: PlatformContext;
async findById(id: string) {
this.ctx?.logger.info("Where are in the repository");
return {
id,
headers: this.$ctx?.request.headers
};
}
}
@Controller("/async-hooks")
export class AsyncHookCtrl {
@Inject()
repository: CustomRepository;
@Get("/:id")
async get(@PathParams("id") id: string) {
return this.repository.findById(id);
}
}
Async Hook context required Node.js at least v13.10.0. `
Install the @tsed/async-hook-context
:
npm install --save @tsed/async-hook-context
Then import @tsed/async-hook-context
in your Server:
import {Configuration} from "@tsed/common";
import "@tsed/async-hook-context";
@Configuration({})
export class Server {}
Please read contributing guidelines here
Thank you to all our backers! 🙏 [Become a backer]
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
The MIT License (MIT)
Copyright (c) 2016 - 2021 Romain Lenzotti
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Add Async Hook context support in Ts.ED
The npm package @tsed/async-hook-context receives a total of 836 weekly downloads. As such, @tsed/async-hook-context popularity was classified as not popular.
We found that @tsed/async-hook-context 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.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.
Security News
New CNA status enables OpenJS Foundation to assign CVEs for security vulnerabilities in projects like ESLint, Fastify, Electron, and others, while leaving disclosure responsibility with individual maintainers.