Skip to content

velizarn/heroku-redis-api

Repository files navigation

heroku-redis-api

Redis + Node.js
A Redis REST API with NodeJS using Expressjs and Redis, Inspired by lucianostraga/heroku-redis-node-rest-api.

Gitpod Ready-to-Code GitHub license

Node 16.18.1 Express 4.18.2 Redis 4.3.0

Setup

Heroku

You can deploy your own copy of the app using the web-based flow:
Deploy

Click on "Deploy to Heroku" button above and follow the instructions:

  • Enter an application name
  • Choose a region
  • Update config vars or leave default values

You can customize the button, for example you might have the following button URL:

<a href="https://heroku.com/deploy?template=https://github.com/velizarn/heroku-redis-api/tree/main&
env[WHITELIST_IP]=11.11.11.11">Deploy to Heroku</a>

This will cause the Heroku app-set interface to prefill IP address for the WHITELIST_IP environment variable and to use specific branch from your repo.

Creating an app without a name

The app name argument is optional. If no app name is specified, a random name will be generated. Since Heroku app names are in a global namespace, you can expect that common names, like “blog” or “wiki”, will already be taken. It’s often easier to start with a default name and rename the app later.

DigitalOcean

You can deploy to DigitalOcean by clicking the button below:
Deploy to DO

Render

You can deploy to Render.com by clicking the button below:
Deploy to Render

Scalingo

You can deploy to Scalingo by clicking the button below:
Deploy on Scalingo

Gitpod

Navigate to https://gitpod.io/#https://github.com/velizarn/heroku-redis-api and follow the instructions. After installation create .env file in your workspace with following parameters:

LOG_LEVEL=info
REDIS_APPKEY_PREFIX=
REDIS_URL=redis://127.0.0.1:6379
WHITELIST_IP=

The most important parameter is REDIS_URL. After creating .env file restart the application, if needed.

Local environment

  1. Install Javascript dependencies (via yarn or npm)

  2. Create .env file with required params, refer to .env.sample

  3. Start the application (npm run start)

How to use it

Available endpoints

GET /help
Displays all available endpoints
GET /info
Returns information and statistics about the server
GET /insomnia.json
Returns data to import a ready-to-use collection into Insomnia Core
GET /keys
Returns all keys, optionally you can set a pattern, e.g. /keys?pattern=name*
GET /get?key=
Get the value of key. If the key does not exist the special value nil is returned. An error is returned if the value stored at key is not a string, because GET only handles string values.
GET /type?key=
Returns the string representation of the type of the value stored at key.
GET /ttl?key=
Returns the remaining time to live of a key that has a timeout.
POST /del
Removes the specified key/s, e.g. keys=foo, keys=foo1,foo2,foo3, etc. A key is ignored if it does not exist.

License

MIT

About

A Redis REST API with NodeJS using Expressjs and Redis

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •