redis-smq-rest-api
Version:
A RESTful API for RedisSMQ
132 lines (93 loc) โข 3.15 kB
Markdown
# RedisSMQ REST API
[](https://github.com/weyoss/redis-smq/releases)
[](https://app.codecov.io/github/weyoss/redis-smq/tree/master/packages/redis-smq-rest-api)
RedisSMQ REST API provides an HTTP interface enabling any web-capable application to interact with the RedisSMQ message
queue using a RESTful API.
## Features
- ๐ Clean and efficient implementation
- โ
Strict request/response validation using [JSON Schema](https://json-schema.org/)
- ๐ Native [OpenAPI v3](https://www.openapis.org/) support and [Swagger UI](https://swagger.io/)
- ๐งช 90%+ code coverage with extensive testing
- ๐ฆ Support for both ESM & CJS modules
## Prerequisites
- [RedisSMQ V8](https://github.com/weyoss/redis-smq) latest release.
## Installation
```bash
# Using npm
npm install redis-smq-rest-api --save
# Using yarn
yarn add redis-smq-rest-api
# Using pnpm
pnpm add redis-smq-rest-api
```
## Version Compatibility
โ ๏ธ Important: Always install matching versions of RedisSMQ packages to ensure compatibility.
```bash
npm install redis-smq@x.x.x redis-smq-rest-api@x.x.x redis-smq-common@x.x.x
```
See [version compatibility](https://github.com/weyoss/redis-smq/blob/master/packages/redis-smq/docs/version-compatibility.md) for details.
## Configuration
The REST API configuration extends the base [RedisSMQ configuration](https://github.com/weyoss/redis-smq/blob/master/packages/redis-smq/docs/configuration.md) with additional API server settings.
### Configuration Options
```typescript
export type THttpApiConfig = {
port?: number;
host?: string;
basePath?: string;
};
export interface IRedisSMQHttpApiConfig extends IRedisSMQConfig {
apiServer?: THttpApiConfig;
}
```
### Configuration Examples
```typescript
import { RedisSmqRestApi } from 'redis-smq-rest-api';
// Basic configuration
const basicConfig: IRedisSMQHttpApiConfig = {
redis: {
client: 'ioredis',
options: {
host: '127.0.0.1',
port: 6379,
},
},
apiServer: {
host: '127.0.0.1',
port: 7210,
},
};
```
## Usage
```typescript
import { RedisSmqRestApi } from 'redis-smq-rest-api';
const config: IRedisSMQHttpApiConfig = {
redis: {
client: ERedisConfigClient.IOREDIS,
options: {
host: '127.0.0.1',
port: 6379,
},
},
apiServer: {
host: '127.0.0.1',
port: 7210,
},
};
const apiServer = new RedisSmqRestApi(config);
apiServer.run();
```
## API Documentation
### Swagger UI
Access the interactive API documentation at:
```text
http://<HOSTNAME>:<PORT>/docs
```
### OpenAPI Specification
Download the OpenAPI specification at:
```text
http://<HOSTNAME>:<PORT>/assets/openapi-specs.json
```
## Available Endpoints
For detailed endpoint documentation, refer to the Swagger UI.
## License
This project is licensed under is released under the [MIT License](https://github.com/weyoss/redis-smq/blob/master/LICENSE).