Giter Club home page Giter Club logo

pg-manati's Introduction

Manati

REST API for PostgreSQL. Forget ORM!

Build Status

Warning

This is still in heavy development and some functionality might change. Be careful when you do an update.

Usage

var manati = require('pg-manati');
var app = manati(
  process.env.DATABASE_URL // your database connection string
);

// Manati uses KoaJS, if you want to extend it to your needs you can use (see http://koajs.com/ for more info)
app.koa.use(function* (next) {
  // add whatever code you want, will be executed first
  yield next;
});

// add authentication routes to the list
app.addPlugin('authentication'));

// add authentication middleware for all routes in the data router (route starting with /data)
app.addPlugin('authorization'), 'data');

if (process.argv[2] === '--setup') {
  app.setup().then(() => {
    console.log('Installation successfull');
    process.exit(0);
  })
}

// this will execute the setup script on every start up, you can choose
app.init({
  logLevel: 'fatal'|'error'|'warn'|'info'|'debug'| // the log level used by the bunyan logger (default 'info'), see https://github.com/trentm/node-bunyan for more info
  logRequest: true|false // whether to log request, using INFO logging level
  logStreams: [] // an array of log streams, see https://github.com/trentm/node-bunyan for more information
});
app.start(3000);

Check our wiki for more information!

Example

Get some users data

GET /data/users?limit=2&name=like::J*
[{"name": "John", "age": 22}, {"name": "Jessie", "age": 30}]

Count some users data

GET /data/count/users/name?name=like::J*
{"count":"2"}

Update some users data

PATCH /data/users?name=eq::Jessie
Content-Type application/json
{
  "age": 23
}
[{"name": "John", "age": 22}, {"name": "Jessie", "age": 23}]

Create some new data

POST /data/users
Content-Type application/json
{
  "name": "Joe",
  "age": 21
}
[{"name": "Joe", "age": 21}]

Delete some users data

DELETE /data/users?name=eq::John
[{"name": "John", "age": 22}]

pg-manati's People

Contributors

sylvainv avatar vitaly-t avatar

Watchers

 avatar  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.