Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/weecraft/nestjs-upstash-redis
NestJs Wrapper for Upstash Redis
https://github.com/weecraft/nestjs-upstash-redis
nestjs npm redis upstash upstash-redis
Last synced: about 17 hours ago
JSON representation
NestJs Wrapper for Upstash Redis
- Host: GitHub
- URL: https://github.com/weecraft/nestjs-upstash-redis
- Owner: weecraft
- License: mit
- Created: 2023-08-25T05:17:02.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-30T11:49:29.000Z (about 1 month ago)
- Last Synced: 2024-10-02T22:15:21.857Z (about 1 month ago)
- Topics: nestjs, npm, redis, upstash, upstash-redis
- Language: TypeScript
- Homepage:
- Size: 172 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# NestJS Upstash Redis
Wrapper for Upstash redis for NestJs
[![NestJS](https://img.shields.io/badge/nestjs-%23E0234E.svg?style=flat&logo=nestjs&logoColor=white)](https://nestjs.com/)
![GitHub contributors](https://img.shields.io/github/contributors/nyomansunima/nestjs-upstash-redis)
![GitHub language count](https://img.shields.io/github/languages/count/nyomansunima/nestjs-upstash-redis)
![GitHub issues](https://img.shields.io/github/issues/nyomansunima/nestjs-upstash-redis)
![GitHub](https://img.shields.io/github/license/nyomansunima/nestjs-upstash-redis)
![GitHub repo size](https://img.shields.io/github/repo-size/nyomansunima/nestjs-upstash-redis)## Table of Contents
- [Installation](#installation)
- [Getting Started](#getting-started)
- [Usage](#usage)
- [Features](#features)
- [Contributing](#contributing)
- [License](#license)## 🚀 Installation
```bash
npm install nestjs-upstash-redis
```## 🤖 Getting Started
Before you start using this package, you need to have a Upstash account and a database set up. If you haven't already done this, head over to the [Upstash site](https://upstash.com) and follow their instructions to get started.
Once you have your Redis credentials, you can configure the package in your NestJS application.
### Configuration
In your NestJS application, create a `.env` file in the root directory and add your Redis secret key:
```dotenv
UPSTASH_REDIS_URL = your redis url
UPSTASH_REDIS_TOKEN = your redis account token
```Make sure to load the `.env` file using a package like `@nestjs/config` in your application's app module file.
### Module Registration
Register the Upstash Redis module in your NestJS application. Import the `UpstashRedisModule` and pass in the configuration options:
```typescript
import { Module } from '@nestjs/common'
import { UpstashRedisModule } from 'nestjs-upstash-redis'@Module({
imports: [
UpstashRedisModule.forRoot({
url: process.env.UPSTASH_REDIS_URL,
token: process.env.UPSTASH_REDIS_TOKEN,
// Other options if needed
}),
],
})
export class AppModule {}
```## 🏀 Usage
With the Upstash Redis module configured, you can now inject the `UpstashRedisService` into your services or controllers to interact with the redis client.
```typescript
import { Injectable } from '@nestjs/common'
import { UpstashRedisService } from 'nestjs-upstash-redis'@Injectable()
export class MyService {
constructor(private readonly cacheService: UpstashRedisService) {}async getCache(key: string): Promise {
const res = await cacheService.get(key)
return res
}// Add more methods to interact with upstash redis as needed
}
```In the example above, we use the `UpstashRedisService.get` method to execute a query against the redis client. You can leverage Upstash redis's powerful query language to perform various operations on your sets.
For more information on the available query functions and how to use them, refer to the [Upstash Redis documentation](https://upstash.com/docs/redis/overall/getstarted).
## ✅ Features
- Seamless integration with NestJS applications.
- Easy-to-use API for interacting with Upstash Redis.
- Utilizes Redis's powerful query language for flexible database operations.
- Configurable and supports multiple environments using environment variables.
## 🩷 Contributing
We welcome contributions from the community to improve this package. If you find any issues or have suggestions for enhancements, please open an issue or submit a pull request.
To contribute please follow the instruction on [Contributing](CONTRIBUTING.md)
Please ensure your code follows the established coding standards and includes appropriate unit tests.
## 🪪 License
This project is licensed under the [MIT License](LICENSE). Feel free to use and modify the code as you see fit.