Giter Club home page Giter Club logo

tupplur's Introduction

tupplur

tupplur

Create a quick rest api with JSON schema. Based on deno kv for storage and ajv for validation.

run locally

Install

deno install -n tupplur --allow-net --allow-read --allow-write --allow-env --unstable https://deno.land/x/tupplur/local.ts

Why all these permissions?

  • --allow-net to accept incoming requests
  • --allow-read to read the database
  • --allow-write to write to the database
  • --allow-env to read the .env file
  • --unstable because deno kv still is

Create an .env file like this

SUPER_USER_KEY=hard_to_guess_string
DB_PATH=test.db
PORT=3333
  • SUPER_USER_KEY is what you are going to use to authenticate when managing collections
  • DB_PATH is where the data is going to be saved (if not defined, will use global deno kv store)
  • PORT the port on which the service runs (defaults to 3333)

Start the server

tupplur

create your first collection

Make a POST request to /collections with name (string) and schema (the JSON schema) in the body and Authentication: Bearer $SUPER_USER_KEY in the headers.

manage access to the collection

Make a POST request to /collections/:name/access, with the same authentication and a body like:

{
  "key": "public",
  "get": true,
  "post": true,
  "patch": true,
  "put": true,
  "delete": true
}

This will allow anyone to make get, post, patch, put and delete requests to /api/:name endpoints. Restrict by omiting methods or setting them to false. By default only the super user has access to the endpoints.

The key public means the users do not need to be authenticated. If you want to use it with other keys than SUPER_USER_KEY but still not it being public, use whatever hard to guess string instead of public and use that in the authentication header. You can have multiple keys with different access.

see the example requests for more endpoints to manage collections.

use the api

Start the server and go to http://localhost:3333 (if you did not change the port) to see and try the available endpoints.

run on deno deploy

Create a project in https://dash.deno.com/projects

Add a SUPER_USER_KEY environment variable to manage collections.

Run:

deployctl deploy --project YOUR_PROJECT_NAME --token=YOUR_TOKEN deploy.ts

tupplur's People

Contributors

idris-maps avatar

Watchers

 avatar

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.