@cargolift-cdi/types
v0.1.126
Published
TypeScript types e interfaces comuns para projetos Cargolift CDI
Maintainers
Readme
@cargolift-cdi/types
Shared TypeScript types and interfaces for Node.js projects. This package is types-only (no runtime JS).
Install
# npm
npm install -D @cargolift-cdi/types
# pnpm
pnpm add -D @cargolift-cdi/types
# yarn
yarn add -D @cargolift-cdi/typesUsage
Use type-only imports to avoid emitting runtime code:
import type { RabbitMQMessage, RabbitMQChannel } from '@cargolift-cdi/types';
function handleMessage(msg: RabbitMQMessage, channel: RabbitMQChannel) {
const correlationId = msg.properties.headers['x-correlation-id'];
// ...process...
channel.ack(msg);
}Example with amqplib:
import amqp from 'amqplib';
import type { RabbitMQMessage } from '@cargolift-cdi/types';
const conn = await amqp.connect(process.env.AMQP_URL!);
const ch = await conn.createChannel();
await ch.assertQueue('jobs');
ch.consume('jobs', (msg) => {
if (!msg) return;
const typedMsg = msg as unknown as RabbitMQMessage;
// use typedMsg.content, typedMsg.properties.headers, etc.
ch.ack(msg);
});What’s inside
rabbitmq.interfaces: tipos para mensagens e canal RabbitMQ.
Notes
- This package ships only
.d.tsfiles. There is no runtime code. - Prefer
import type(TS 4.5+) so bundlers/Node don’t try to load a runtime module.
Development
npm run build– emits.d.tsonly intodist/.
Publishing
- Update version in
package.json. npm publish --access public.
The package only ships .d.ts files (no runtime JS).
License
MIT
