STOR provides a JSON database with the power of HTTP requests
You need to install NodeJS first
Just clone the repository :
git clone https://www.github.com/dimensi0n/stor.git
And run :
npm install
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
If you want to run it just for testing you can launch it with this command :
npm start
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))
users.SelectAll()
.then(res => res.json())
.then(body => console.log(body.content))
users.Create({name:'pierre'})
.then(res => res.text())
.then(body => console.log(body))
users.Get('name', 'pierre')
.then(res => res.text())
.then(body => console.log(body))
Get user when name is 'pierre'
users.Put('name', 'pierre', 'jean')
.then(res => res.text())
.then(body => console.log(body))
Update user when name is 'pierre' to 'jean'
users.Delete('name', 'jean')
.then(res => res.text())
.then(body => console.log(body))
Delete user when name is 'jean'