All Projects → rehacktive → caffeine

rehacktive / caffeine

Licence: GPL-3.0 License
A basic REST service for JSON data - enough for prototyping and MVPs!

Programming Languages

go
31211 projects - #10 most used programming language
HTML
75241 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to caffeine

Perfect-JSON-API
An Example JSON API for Perfect
Stars: ✭ 43 (-96.28%)
Mutual labels:  json-api
motis
Intermodal Mobility Information System
Stars: ✭ 45 (-96.1%)
Mutual labels:  json-api
ctuning-datasets-min
Public data sets and their properties in the Collective Knowledge Format with JSON API and JSON meta information to be easily pluggable to customizable and reproducible CK experimental workflows (such as collaborative program analysis and optimization):
Stars: ✭ 26 (-97.75%)
Mutual labels:  json-api
nosqlilab
A lab for playing with NoSQL Injection
Stars: ✭ 90 (-92.21%)
Mutual labels:  nosql
Vox
Swift JSON:API client framework
Stars: ✭ 47 (-95.93%)
Mutual labels:  json-api
cloud-enablement-aws
Enabling MarkLogic in the cloud (AWS)
Stars: ✭ 18 (-98.44%)
Mutual labels:  nosql
Cosmos.Identity
A Cosmos storage provider for ASP.NET Core Identity.
Stars: ✭ 26 (-97.75%)
Mutual labels:  nosql
groq-cli
Run GROQ in your command line
Stars: ✭ 139 (-87.97%)
Mutual labels:  json-api
manon
🧪 Play with SpringBoot 2, JWT, Querydsl, GraphQL, Docker, ELK, PostgreSQL, MariaDB, Redis, MongoDB, Flyway, Maven, Gradle, TestNG, JUnit5, JaCoCo, GreenMail, CI, Quality Gates, Prometheus, Gatling, etc.
Stars: ✭ 26 (-97.75%)
Mutual labels:  nosql
PlaceTracking
Simple and free to use API for time and location tracking
Stars: ✭ 21 (-98.18%)
Mutual labels:  json-api
JSONCustomLintr
Library to allow creation, running, and reporting of custom lint rules for JSON files
Stars: ✭ 19 (-98.35%)
Mutual labels:  json-api
biolink-model
Schema and generated objects for biolink data model and upper ontology
Stars: ✭ 83 (-92.81%)
Mutual labels:  json-api
pickledb-rs
PickleDB-rs is a lightweight and simple key-value store. It is a Rust version for Python's PickleDB
Stars: ✭ 116 (-89.96%)
Mutual labels:  nosql
json
a portable, powerful and pure functional JSON library for Scheme
Stars: ✭ 40 (-96.54%)
Mutual labels:  json-api
skytable
Skytable is an extremely fast, secure and reliable real-time NoSQL database with automated snapshots and TLS
Stars: ✭ 696 (-39.74%)
Mutual labels:  nosql
basic-transport-info-app
A progressive web app to show direct & indirect buses / transport between two places / cities / stops .Show next schedule & travel duration. Algorithm to calculate indirect buses on basis of their schedule time. Voice search . Locate nearest city/stop by gps. Bus timetable.
Stars: ✭ 12 (-98.96%)
Mutual labels:  json-api
aiohttp json api
JSON API implementation for aiohttp
Stars: ✭ 18 (-98.44%)
Mutual labels:  json-api
jify
JSON indexed file database/querying library/tool
Stars: ✭ 17 (-98.53%)
Mutual labels:  nosql
Scrython
A python wrapper for the Scryfall API
Stars: ✭ 87 (-92.47%)
Mutual labels:  json-api
go-respond
A Go package for handling common HTTP JSON responses.
Stars: ✭ 45 (-96.1%)
Mutual labels:  json-api

caffeine - minimum viable backend

A very basic REST service for JSON data - enough for prototyping and MVPs!

Features:

  • no need to set up a database, all data is managed automagically*
  • REST paradigm CRUD for multiple entities/namespaces
  • JWT authentication
  • realtime notifications (HTTP/SSE)
  • schema validation
  • autogenerates Swagger/OpenAPI specs
  • search using jq like syntax (see https://stedolan.github.io/jq/manual/)
  • CORS enabled
  • easy to deploy as container

Currently supports:

  • in memory database (map)
  • sqlite
  • postgres
  • filesystem storage

For a sample Vue app using caffeine see: https://gist.github.com/calogxro/6e601e07c2a937df4418d104fb717570

How to

Simply start the server with:

go run caffeine.go

optional params are:

Usage of caffeine:
  -AUTH_ENABLED=false: enable JWT auth
  -DB_TYPE="memory": db type to use, options: memory | postgres | fs | sqlite
  -DB_PATH="./data": path of the file storage root or sqlite database
  -IP_PORT=":8000": ip:port to expose
  -PG_HOST="0.0.0.0": postgres host (port is 5432)
  -PG_PASS="": postgres password
  -PG_USER="": postgres user

Store a new "user" with an ID and some json data:

> curl -X POST -d '{"name":"jack","age":25}'  http://localhost:8000/ns/users/1
{"name":"jack","age":25}

the value will be validated, but it could be anything (in JSON!)

retrieve later with:

> curl http://localhost:8000/ns/users/1
{"name":"jack","age":25}

All operations

Insert/update

> curl -X POST -d '{"name":"jack","age":25}'  http://localhost:8000/ns/users/1
{"name":"jack","age":25}

Delete

> curl -X DELETE http://localhost:8000/ns/users/1

Get by ID

> curl http://localhost:8000/ns/users/1
{"name":"jack","age":25}

Get all values for a namespace

> curl http://localhost:8000/ns/users | jq 
[
  {
    "key": "2",
    "value": {
      "age": 25,
      "name": "john"
    }
  },
  {
    "key": "1",
    "value": {
      "age": 25,
      "name": "jack"
    }
  }
]

Get all namespaces

> curl http://localhost:8000/ns
["users"]

Delete a namespace

> curl -X DELETE http://localhost:8000/ns/users
{}

Search by property (jq syntax)

> curl http://localhost:8000/search/users?filter="select(.name==\"jack\")"  | jq
{
  "results": [
    {
      "key": "1",
      "value": {
        "age": 25,
        "name": "jack"
      }
    }
  ]
}

JWT Authentication

There's a first implementation of JWT authentication. See documentation about JWT

Realtime Notifications

Using HTTP Server Sent Events (SSE) you can get notified when data changes, just need to listen from the /broker endpoint:

curl http://localhost:8000/broker

and for every insert or delete an event will be triggered:

{"event":"ITEM_ADDED","namespace":"test","key":"1","value":{"name":"john"}}
...
{"event":"ITEM_DELETED","namespace":"test","key":"1"}
...

Swagger/OpenAPI specs

After you add some data, you can generate the specs with:

curl -X GET http://localhost:8000/openapi.json

or you can just go to http://localhost:8000/swaggerui/ and use it interactively!

Schema Validation

You can add a schema for a specific namespace, and only correct JSON data will be accepted

To add a schema for the namespace "user", use the one available in schema_sample/:

curl --data-binary @./schema_sample/user_schema.json http://localhost:8000/schema/user

Now only validated "users" will be accepted (see user.json and invalid_user.json under schema_sample/)

Run as container

docker build -t caffeine .

and then run it:

docker run --publish 8000:8000 caffeine

Run with Postgres

First run an instance of Postgres (for example with docker):

docker run -e POSTGRES_USER=caffeine -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres:latest

Then run caffeine with the right params to connect to the db:

DB_TYPE=postgres PG_HOST=0.0.0.0 PG_USER=caffeine PG_PASS=mysecretpassword go run caffeine.go

(params can be passed as ENV variables or as command-line ones)

A very quick to run both on docker with docker-compose:

docker-compose up -d
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].