
Security News
Open Source Maintainers Demand Ability to Block Copilot-Generated Issues and PRs
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
@djpfs/adonisjs-microservices
Advanced tools
A package that allows your AdonisJs applications to be used as microservices, enabling communication between them through different protocols
This package is designed to simplify communication between microservices in your Adonis application. Currently, it supports integration with Apache Kafka and plans to add support for other messaging systems such as RabbitMQ and gRPC in the future.
You can install this package via npm with the following command:
npm i @djpfs/adonisjs-microservices
After installation, execute the following command to configure the package:
node ace configure @djpfs/adonisjs-microservices
This command will set up the necessary files for the package to function in your project.
To use Kafka as the transport system, you must first install the kafkajs
package:
npm i kafkajs
Next, add the following configurations to your .env
file, replacing the values according to your environment:
KAFKA_CLIENT_ID='service-gateway'
KAFKA_GROUP_ID='gateway'
KAFKA_BROKERS='kafka1:9092,kafka2:9093,kafka3:9094'
KAFKA_SSL=false
KAFKA_SASL=false
KAFKA_SASL_MECHANISM='scram-sha-512'
KAFKA_SASL_USERNAME='username'
KAFKA_SASL_PASSWORD='password'
KAFKA_LOG_LEVEL=4
To use the package, import the MsMessage
and KafkaPayload
classes into your controller file. Then, use the MsMessage
decorator to specify the topic you want to listen to:
import { MsMessage } from "App/Decorators/MsMessage";
import { KafkaPayload } from "App/Helpers/Types/Microservice";
export default class AuthController {
@MsMessage('kafka.auth.login')
public async login(message: KafkaPayload) {
console.log(message.message)
}
}
The decorator expects a string as a parameter, which should contain at least one dot (.) to separate the transport name from the topic name. The transport name should match what you defined in the package configuration file.
For example, kafka.auth.login
, where "kafka" is the transport name, and "auth.login" is the topic name.
To send messages, import the Transports
and KafkaTransport
classes into your controller file. Then, use the send
method of the transport to send the message:
import Transports from "@ioc:Microservice/Transports";
import KafkaTransport from '@djpfs/adonisjs-microservices/build/src/transports/kafka'
export default class AuthController {
public async sendMessage() {
const transport: KafkaTransport = Transports.getTransport('kafka')
await transport.producer.send({
topic: 'auth.login',
messages: [
{ value: 'Hello KafkaJS user!' },
],
})
}
}
You can configure Kafka with all available options from the kafkajs
package by editing the settings in the config/microservices.ts
file.
FAQs
A package that allows your AdonisJs applications to be used as microservices, enabling communication between them through different protocols
We found that @djpfs/adonisjs-microservices 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
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
Research
Security News
Malicious Koishi plugin silently exfiltrates messages with hex strings to a hardcoded QQ account, exposing secrets in chatbots across platforms.
Research
Security News
Malicious PyPI checkers validate stolen emails against TikTok and Instagram APIs, enabling targeted account attacks and dark web credential sales.