@resilientmq/types__mongoose-connector v0.1.1
@resilientmq/types__mongoose-connector
TypeScript type definitions for the @resilientmq/mongoose-connector library.
This package defines all typings required for the MongoDB-based connector for ResilientMQ.
Table of Contents
Installation
This is a TypeScript declaration-only package available via the npm registry.
Before installing, ensure you have a package.json set up:
npm init -yThen install this types package:
npm install @resilientmq/types__mongoose-connector --save-devPurpose
This package provides type definitions used in the @resilientmq/mongoose-connector runtime.
It allows the use of custom event schemas in MongoDB while preserving type safety and compatibility with the core @resilientmq/core logic.
Examples
EventSerializer
import { EventSerializer } from '@resilientmq/types__mongoose-connector';
const customSerializer: EventSerializer = {
toStorageFormat(event) {
return {
_id: event.id,
body: event.payload,
customStatus: event.status
};
},
fromStorageFormat(doc) {
return {
id: doc._id,
messageId: doc._id,
payload: doc.body,
status: doc.customStatus,
type: 'custom.type'
};
},
getStatusField() {
return 'customStatus';
}
};MongooseConnectorConfig
import { MongooseConnectorConfig } from '@resilientmq/types__mongoose-connector';
const config: MongooseConnectorConfig = {
mongo: {
uri: 'mongodb://localhost:27017/mydb',
options: {}
},
rabbit: {
consumer: {
connection: 'amqp://localhost',
consumeQueue: {
queue: 'my.queue',
options: { durable: true }
},
eventsToProcess: [
{
type: 'user.created',
handler: async (payload) => console.log(payload)
}
],
model: MyConsumerModel,
serializer: customSerializer
},
publisher: {
connection: 'amqp://localhost',
exchange: {
name: 'my.exchange',
type: 'fanout',
options: { durable: true }
},
model: MyPublisherModel,
serializer: customSerializer
}
},
logLevel: 'info'
};Docs
See Mongoose Connector Docs for full API reference and usage patterns.
Issues
🐛 Bugs
Please report any issues regarding typing mismatches or missing types.
💡 Feature Requests
Want additional type helpers or utilities? Let us know.