Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
tsed-bee-queue
Advanced tools
Bee-queue for Ts.ED framework
This provides Redis-based job queueing services built on top of Bee-queue in Ts.ED framework. With some little configuraitons you can have your web service running as a queue system that handle different jobs as you define.
npm install https://github.com/alexdonh/tsed-bee-queue.git
// or yarn
yarn add https://github.com/alexdonh/tsed-bee-queue.git
Your application code structure could look like this:
.
├── ...
├── src -- TypeScript source
│ ├── controllers
│ ├── models
│ ├── queues -- Add this directory to store all of your jobs
│ │ ├── FooQueue.ts
│ │ ├── BarQueue.ts
│ │ └── ...
│ ├── ...
│ ├── index.ts
│ └── Server.ts
├── package.json
├── tsconfig.json
├── tsconfig.compile.json
└── ...
import {Inject} from "@tsed/di";
import {Logger} from "@tsed/logger";
import {Job, DoneCallback} from "bee-queue";
import {Queue, QueueProvider} from "tsed-bee-queue";
@Queue({name: "foo", concurrency: 2})
export class FooQueue implements QueueProvider {
@Inject()
readonly logger: Logger;
$exec(job: Job<any>) {
this.logger.debug(job);
// do something
// MUST return Promise
}
// or
// $exec(job: Job<any>, done: DoneCallback<any>) {
// this.logger.debug(job);
// // do something
// // call done ONCE
// }
}
You can do this in different ways, below is an example in Server.ts
:
import {Configuration} from "@tsed/di";
import "tsed-redis"; // Recommended as it use DI factory for Redis client to avoid creating connections
import "tsed-bee-queue";
import providers from "./queues";
...
@Configuration({
...
redis: {
host: "localhost",
port: 6379,
...
},
queue: {
providers // MUST
}
})
export class Server {
...
}
To create and send job
import {Controller, Get, Inject} from "@tsed/common";
import {QueueService} from "tsed-bee-queue";
@Controller("/foo")
export class FooController {
@Inject()
readonly queueService: QueueService;
@Inject()
readonly logger: Logger;
@Get("/new")
async index() {
const queue = this.queueService.get("foo"); // name of the job queue
await queue.createJob({hello: "world"}).save();
}
}
This job will be sent to queue and handled by FooQueue
. This doesn't have to be in the same application. You can send job from different apps as well.
This library also supports monitoring your queues using bee-queue/bull-arena
.
In Server.ts
:
import {Configuration} from "@tsed/di";
import "tsed-redis";
import "tsed-bee-queue";
import {ArenaMiddleware} from "tsed-bee-queue";
...
@Configuration({
...
queue: {
providers,
arenaListenOptions: {
basePath: "/arena",
disableListen: true // to run it on your running server or you can set a different host/port to run another separate server
}
}
})
export class Server {
$afterRoutesInit(): void {
this.app.all("/arena/*", ArenaMiddleware); // route all requests to Arena middleware
}
}
MIT License
Copyright (c) 2021 Alex Do
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
Bee-queue for Ts.ED framework
The npm package tsed-bee-queue receives a total of 3 weekly downloads. As such, tsed-bee-queue popularity was classified as not popular.
We found that tsed-bee-queue 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.