Coder Social home page Coder Social logo

mrrfv / kvdb Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 118 KB

Postgres-based key-value database backend server, perfect for simple applications that need basic cloud storage / syncing

License: MIT License

JavaScript 96.40% Dockerfile 3.60%
backend database firebase-alternative key-value postgres postgresq

kvdb's Introduction

kvdb

Very simple postgres-based key-value database server.

Why?

Firebase, Appwrite, Supabase and other similar services have limited free plans, usually based around the amount of daily reads, writes or simultaneous connections. This is a problem for projects with no budget that need to store a small amount of data that is accessed or modified very frequently.

By using this project, you can host your own key-value database server, with no limits on reads, writes or connections. The only limit is the amount of storage space available on your server.

Features

  • Very simple API - create, update, read and delete - that's it
  • Meant to be directly connected to from the client, no additional backend needed
  • No authentication (key name is considered secret) - please keep this in mind when using this project
  • Optional response speed throttling
  • Optional key expiration
  • Key/value length limits
  • Read-only keys that respond with the same value but don't allow writes
  • CORS support

Usage

Requirements

  • PostgreSQL database
  • Node.js 18+ and npm

Installation

  1. Clone this repository
  2. Run npm install
  3. Copy .env.example to .env and edit it to match your database configuration
  4. Run node db-setup.js to create the database table. Define the DANGEROUS_DELETE_TABLE environment variable to delete the existing table first (this will delete all data).
  5. Run node index.js to start the server

HTTP API

GET /key?name=KEY_NAME

Returns the value of the key KEY_NAME.

Response example:

{
  "value": "Hello, world!"
}

POST /key

Request body:

{
  "name": "Optional key name"
}

Response example:

{
  "success": true,
  "name": "Key name",
  "name_readonly": "Read-only key name",
}

Creates a key. An optional key name can be specified in a name JSON parameter. If no name is specified, a secure random string will be used. The key name must contain no spaces or special characters. name_readonly is the name of the read-only key that is created alongside the regular key.

If a key is invalid, the server will generate a new key name and return it in the response.

PATCH /key

Request body:

{
  "name": "Key name",
  "value": "New value"
}

Response example:

{
  "success": true
}

Updates the value of the key namme to value.

DELETE /key?name=KEY_NAME

Response example:

{
  "success": true
}

Deletes the key KEY_NAME.

Important

This is a very simple project that was created for personal use. There is no guarantee that it is secure or that it will work for your use case. Use at your own risk.

kvdb's People

Contributors

mrrfv avatar renovate[bot] avatar

Watchers

 avatar  avatar

kvdb's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

dockerfile
Dockerfile
github-actions
.github/workflows/codacy.yml
  • actions/checkout v4
  • codacy/codacy-analysis-cli-action 740bfaa8ff39510e8b8049e711ac5c801d194199
  • github/codeql-action v3
.github/workflows/docker-image.yml
  • actions/checkout v4
  • docker/login-action v3
  • docker/setup-qemu-action v3
  • docker/setup-buildx-action v3
  • docker/build-push-action v6
npm
package.json
  • @fastify/compress ^7.0.0
  • @fastify/cors ^9.0.0
  • @fastify/postgres ^5.2.0
  • @fastify/rate-limit ^9.0.0
  • @fastify/throttle ^2.0.0
  • dotenv ^16.3.1
  • fastify ^4.23.2
  • node >=18

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.