radenkovic / krang

Totally (almost) serverless concept that allows you to access DB from front-end. Krang! πŸ˜‚

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Krang

Totally (well, almost) serverless concept that allows you to query DB from front-end. Krang! πŸ˜‚

Krang in action

For Your Safety

Concept of Krang is to "open the portal" to database, so it can be (almost) directly accessed from front-end. At first that sounds like totally Krang-ish idea and totally unsafe option, by configuring user roles in your database (for example allowing read-only particular tables) or if you trust your users (in Krang you can integrate some authentication mechanism) to give some write permissions too.

Another use of Krang would be for boostrapping an app, you can design your schema and move queries to backend later (very nice if it's Node).

Idea of writing plain SQL in javascript is also very Krang-ish but Squel.js can be good option.

IMPORTANT: Using Krang in production environment can worsen Global Warming!

Installation

  1. git clone https://github.com/radenkovic/krang
  2. cd krang
  3. yarn or npm i
  4. Open krang.js and set up your database (or you can use .env file)
  5. npm start

API

To query Krang you there is only one endpoint:

POST /krang

which uses only one parameter: query.

Stack

Needless to say it's written in one file (krang.js), runs on Node/Express, and connected to MySQL database (but it can be anything else, literally). Frontend sample is written with jQuery so everyone can understand it.

Environment Variables

You can set up your environment variables in .env (dotenv) file:

  1. DB_HOST=localhost
  2. DB_USER=root
  3. DB_PASSWORD=""
  4. DB_DATABASE=krang
  5. DB_PORT=3306

Contributions

If you find this idea interesting, you can fork it and contribute. Krang will love it.

About

Totally (almost) serverless concept that allows you to access DB from front-end. Krang! πŸ˜‚


Languages

Language:CSS 37.5%Language:HTML 34.1%Language:JavaScript 28.4%