diff --git a/configure.ts b/configure.ts index c8e8267..482a79a 100644 --- a/configure.ts +++ b/configure.ts @@ -19,7 +19,7 @@ export async function configure(command: ConfigureCommand) { */ await codemods.updateRcFile((rcFile: any) => { rcFile.addProvider('rabbitmq-adonis-v6/rabbitmq_provider') - rcFile.addPreloadFile('#start/rabbit', ['console']) + rcFile.addPreloadFile('#start/rabbit', ['web']) }) /** @@ -30,7 +30,7 @@ export async function configure(command: ConfigureCommand) { RABBITMQ_USER: '', RABBITMQ_PASSWORD: '', RABBITMQ_PORT: '', - RABIITMQ_PROTOCOL: 'ampq', + RABBITMQ_PROTOCOL: 'ampq', RABBITMQ_HEARTBEAT: 60, }) @@ -43,7 +43,7 @@ export async function configure(command: ConfigureCommand) { RABBITMQ_USER: 'Env.schema.string()', RABBITMQ_PASSWORD: 'Env.schema.string()', RABBITMQ_PORT: 'Env.schema.number()', - RABIITMQ_PROTOCOL: 'Env.schema.string()', + RABBITMQ_PROTOCOL: 'Env.schema.string()', RABBITMQ_HEARTBEAT: 'Env.schema.number.optional()', }, leadingComment: 'Variables for Rabbitmq', diff --git a/package-lock.json b/package-lock.json index a002844..9919cd5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rabbitmq-adonis-v6", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rabbitmq-adonis-v6", - "version": "1.0.3", + "version": "1.0.4", "license": "MIT", "dependencies": { "@types/amqplib": "^0.10.5", diff --git a/package.json b/package.json index a5efd1b..9fb5866 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rabbitmq-adonis-v6", - "version": "1.0.4", + "version": "1.0.5", "description": "AdonisJS RabbitMQ provider", "main": "build/index.js", "engines": { diff --git a/readme.md b/readme.md index 6c4541b..fd81080 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # adonis-rabbit -`rabbitmq-adonis-v6` is a RabbitMQ provider for [Adonis](https://github.com/adonisjs/core). +`rabbitmq-adonis-v6` is a RabbitMQ provider for [Adonis](https://adonisjs.com/). ## Getting Started @@ -35,7 +35,7 @@ Make sure to set the correct values to the enviroment variables so `rabbitmq-ado ### Sending messages to an queue ```ts -import Rabbit from 'rabbitmq-adonis-v6' +import { Rabbit } from 'rabbitmq-adonis-v6' import router from '@adonisjs/core/services/router' Route.get('/', async () => { @@ -56,7 +56,7 @@ Notice doesn't really makes sense to subscribe to an queue inside a controller, Inside `start/rabbit.ts`: ```ts -import Rabbit from 'rabbitmq-adonis-v6' +import { Rabbit } from 'rabbitmq-adonis-v6' async function listen() { await Rabbit.assertQueue('my_queue') @@ -78,7 +78,7 @@ This will log every message sent to my queue `my_queue`. #### Import ```ts -import Rabbit from 'rabbitmq-adonis-v6' +import { Rabbit } from 'rabbitmq-adonis-v6' ``` #### `assertQueue()` @@ -214,6 +214,14 @@ Retrieves the amqplib's Channel instance. If there's not a connection, it'll be await Rabbit.getChannel() ``` +#### `validateConnection()` + +Indicate if has an active connection + +```ts +await Rabbit.validateConnection() +``` + #### `closeChannel()` Closes the channel. @@ -226,7 +234,7 @@ Closes the connection. ### Message -When consuming messages through [`consumeFrom`](https://github.com/jotaajunior/adonis-rabbit#consumefrom), you'll receive in the callback a Message instance. +When consuming messages through [`consumeFrom`](https://github.com/mvargaslandolfi/rabbitmq-adonis-v6#consumefrom), you'll receive in the callback a Message instance. This slightly different from amqplib approach. For example: @@ -318,3 +326,7 @@ Parameters: In your .env you have to put the service container name, for example: `RABBITMQ_HOSTNAME={your_docker_container_service_name}` + +## Credits + +Part of the code for this package has been taken and adapted from the RabbitMQ package for Adonis v5. You can find the original package [here](https://github.com/jotaajunior/adonis-rabbit). \ No newline at end of file diff --git a/stubs/start/rabbit.stub b/stubs/start/rabbit.stub index 8bf85d7..d62bee7 100644 --- a/stubs/start/rabbit.stub +++ b/stubs/start/rabbit.stub @@ -2,7 +2,7 @@ exports({ to: app.startPath('rabbit.ts') }) }}} -import rabbitmq from 'rabbitmq-adonis-v6' +import { Rabbit } from 'rabbitmq-adonis-v6' async function listen() { await Rabbit.assertQueue('my_queue')