flume-cloud-services / stor

[DEPRECATED] STOR provides a JSON database with the power of HTTP requests πŸš€

Home Page:https://flume-cloud-services.github.io/stor/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

STOR provides a JSON database with the power of HTTP requests

1. Installation

You need to install NodeJS first

Just clone the repository :

git clone https://www.github.com/dimensi0n/stor.git

And run :

npm install

2. Configuration

Stor uses Environment variable :

STOR_MONGO_URI is the link to your MongoDB database
STOR_PORT is the port number you want the database to run on
STOR_PASSWORD is the token you will write for each request on the request header
STOR_CORS is the Cors config object : 1 if cors is enabled, by default is true; 0 if cors is disabled
STOR_CORS_WHITELIST (optionnal, the domain you want to be validate) Example: STOR_CORS_WHITELIST=www.mydomain.com,www.myotherdomain.com

Once you finished to complete this fields just transpile it :

npx tsc

3. Run it

If you want to run it just for testing you can launch it with this command :

npm start

4. Use it

Install the official js library :

npm install stor-js

Connect to your Stor database and select your table :

const stor = require("stor-js");

const Stor = new stor.Stor("link to your Stor database", "STOR_PASSWORD");

let users = Stor.Table("users");

Then init your Stor database :

users.Init([])
    .then(res => res.text())
    .then(body => console.log(body))

Select All :

users.SelectAll()
    .then(res => res.json())
    .then(body => console.log(body.content))

Create :

users.Create({name:'pierre'})
    .then(res => res.text())
    .then(body => console.log(body))

Get where :

users.Get('name', 'pierre')
    .then(res => res.text())
    .then(body => console.log(body))

Get user when name is 'pierre'

Update :

    users.Put('name', 'pierre', 'jean')
    .then(res => res.text())
    .then(body => console.log(body))

Update user when name is 'pierre' to 'jean'

Delete :

    users.Delete('name', 'jean')
    .then(res => res.text())
    .then(body => console.log(body))

Delete user when name is 'jean'

About

[DEPRECATED] STOR provides a JSON database with the power of HTTP requests πŸš€

https://flume-cloud-services.github.io/stor/

License:MIT License


Languages

Language:TypeScript 76.9%Language:JavaScript 19.8%Language:Dockerfile 3.3%