npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nestjs-upstash-redis

v1.0.0

Published

NestJs wrapper for upstash redis

Downloads

8

Readme

NestJS Upstash Redis

Wrapper for Upstash redis for NestJs

NestJS GitHub contributors GitHub language count GitHub issues GitHub GitHub repo size

Table of Contents

🚀 Installation

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 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:

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:

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.

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<any> {
    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.

✅ 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

Please ensure your code follows the established coding standards and includes appropriate unit tests.

🪪 License

This project is licensed under the MIT License. Feel free to use and modify the code as you see fit.