Serve read-only Redis data over a HTTP API with auth

Overview

Redis data exposer

This was created for Cliptok and not intended for use outside of it. Use at your own peril.

This application will serve an API that will return read-only data from your configured Redis server.

Disclaimer

The code here is not the best code it could have been. I am not overly proficient with JavaScript and this code was written to serve a single purpose. Please be gentle.

If you use this for some reason and have an issue, please report it.

Setup

Environment variables (none are required):

  • PORT: The port to listen on. Default is 3000.
  • REDIS_URL: URL pointing to the redis server to connect to. Default is localhost.
  • SECRET: The secret to pass for authorization. Default is superscarysecret.

Run Docker image ghcr.io/erisa/redis-exposer or clone, yarn and yarn start.

Usage

Required: Authorization header or secret query parameter with the correct value.

GET /:key

If key held value, you would get something like:

{
    "code": 200,
    "data": "value"
}

If the value is JSON, it will be parsed. For example if key held {"thing": "otherthing"} you would get:

{
    "code": 200,
    "data": {
        "thing": "otherthing"
    }
}

Big numbers will be converted to strings. Or maybe it was all numbers, I don't remember.

If the key is a list, it will be returned as such:

{
    "code": 200,
    "data": [
        "thing",
        "otherthing"
    ]
}

You can also put JSON inside a list item, if you want.

If the value is a hash, it will return all items, same as JSON:

{
    "code": 200,
    "data": {
        "thing": "otherthing"
    }
}

GET /:key/:value

If the key is not a hash, you get yelled at:

{
  "code": 400,
  "message": "Bad request, key is not a hash and cannot be accessed like a hash. Try /:key."
}

If the value does not exist, you also get yelled at:

{
  "code": "404",
  "message": "Key/value pair does not exist or is null."
}

But if it does exist, you get data:

{
    "code": 200,
    "data": "thing in a hash"
}

The end

That's it. There's nothing more to tell.

You might also like...

Serverless URL Shortener made with Next.js + Redis.

Serverless URL Shortener made with Next.js + Redis.

linki: a place for your links linki is a url shortener made with next.js and redis! built with simplicity in mind, it's all in one page. deploy your o

Sep 15, 2022

A simple Node.js APIBAN client for downloading banned IPs and inserting them into a redis set

apiban-redis A simple Node.js APIBAN client for downloading banned IPs and inserting them into a redis set. Installation This utility can be run as a

Apr 5, 2022

This project demonstrates how you can use the multi-model capabilities of Redis to create a real-time stock watchlist application.

This project demonstrates how you can use the multi-model capabilities of Redis to create a real-time stock watchlist application.

Introduction This project demonstrates how you can use Redis Stack to create a real-time stock watchlist application. It uses several different featur

Jan 2, 2023

Full type-safe Redis PubSub with Zod

redis-pubsub Full type-safe Redis PubSub system with async iterators Features Type-safety with Zod Out-of-the-box support for Date/Map/Set/BigInt seri

Dec 21, 2022

🪦 Redis Key Value store backed by IPFS

🪦 Redis Key Value store backed by IPFS

🪦 RipDB 🪦 A snappy, decentralized JSON store perfect for fast moving web3 builders. Redis + IPFS = RIP = 😍 Install With a Package Manager (browser

Dec 13, 2022

An open-source link shortener built with Vercel Edge Functions and Upstash Redis.

Dub An open-source link shortener built with Vercel Edge Functions and Upstash Redis. Introduction · Deploy Your Own · Contributing Introduction Dub i

Jan 5, 2023

TypeScript Data Structures that you need!

TypeScript Data Structures that you need!

TSDS TypeScript Data Structures that you need! Doc Website Introduction A data structure is a way to store and organize data in order to facilitate ac

Dec 8, 2022

SSHOT is a ✨ Web Screenshot API ✨ with caching kept in mind!

SSHOT is a ✨ Web Screenshot API ✨ with caching kept in mind!

label icon Quick Start rocket Welcome to SSHOT (/s:shot/) SSHOT is a ✨ Web Screenshot API ✨ with caching kept in mind! Just pass in the parameters for

Dec 24, 2022

Type-safe and Promisified API for Web Worker and Iframe

💛 You can help the author become a full-time open-source maintainer by sponsoring him on GitHub. typed-worker Install npm i typed-worker Usage Create

Dec 31, 2022
Comments
  • Code cleanup and misc

    Code cleanup and misc

    • js style lints
      • Added yarn lint - using semistandard. (feel free to switch to standard if desired, since there was an inconsistency of with and without semicolons)
      • Use switch case instead of if/else if
      • Use Array.forEach() instead of for const in
      • Consistency between functions and arrow functions
      • Only try parsing Redis response if it isn't parsed already (aka. type string)
    • Add string key support
    • Removed application/json setHeader due to redundancy (express already deals with this)
    • Misc inconsistencies fixed
    • Switched from node-redis to ioredis (probably better performance, lower size)
    • lock dependencies
    opened by JeDaYoshi 2
Owner
Erisa A
22 y.o. female weirdo with a passion for making a mess of things. Avatar credit: https://www.pixiv.net/i/50457051
Erisa A
Cache is easy to use data caching Node.js package. It supports Memcached, Redis, and In-Memory caching engines.

Cache Cache NPM implements wrapper over multiple caching engines - Memcached, Redis and In-memory (use with single threaded process in development mod

PLG Works 49 Oct 24, 2022
Kue is a priority job queue backed by redis, built for node.js.

Kue Kue is no longer maintained Please see e.g. Bull as an alternative. Thank you! Kue is a priority job queue backed by redis, built for node.js. PRO

Automattic 9.4k Dec 20, 2022
A simple, fast, robust job/task queue for Node.js, backed by Redis.

A simple, fast, robust job/task queue for Node.js, backed by Redis. Simple: ~1000 LOC, and minimal dependencies. Fast: maximizes throughput by minimiz

Bee Queue 3.1k Jan 5, 2023
Redis Simple Message Queue

Redis Simple Message Queue A lightweight message queue for Node.js that requires no dedicated queue server. Just a Redis server. tl;dr: If you run a R

Patrick Liess 1.6k Dec 27, 2022
BullMQ - Premium Message Queue for NodeJS based on Redis

The fastest, most reliable, Redis-based distributed queue for Node. Carefully written for rock solid stability and atomicity. Read the documentation F

Taskforce.sh Inc. 3.1k Dec 30, 2022
Nodejs Background jobs using redis.

node-resque: The best background jobs in node. Distributed delayed jobs in nodejs. Resque is a background job system backed by Redis (version 2.6.0 an

Actionhero 1.2k Jan 3, 2023
A simple high-performance Redis message queue for Node.js.

RedisSMQ - Yet another simple Redis message queue A simple high-performance Redis message queue for Node.js. For more details about RedisSMQ design se

null 501 Dec 30, 2022
Redis-backed task queue engine with advanced task control and eventual consistency

idoit Redis-backed task queue engine with advanced task control and eventual consistency. Task grouping, chaining, iterators for huge ranges. Postpone

Nodeca 65 Dec 15, 2022
A fast, robust and extensible distributed task/job queue for Node.js, powered by Redis.

Conveyor MQ A fast, robust and extensible distributed task/job queue for Node.js, powered by Redis. Introduction Conveyor MQ is a general purpose, dis

Conveyor MQ 45 Dec 15, 2022
egg.js(jwt) + mysql(sequelize) + redis + docker + docker-compose + nginx + vue + element-ui 全栈获取省市区数据(统计局数据)【工具】项目,实现在docker环境中一键部署

Egg-spider Preview 线上预览地址 (https://ronaldoxzb.com/) admin admin Project description [后端]egg.js(jwt) + mysql(sequelize) + redis + docker + docker-compo

null 11 Sep 29, 2022