Socket
Book a DemoInstallSign in
Socket

open-parse

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

open-parse

The collection of middleware which provides REST API interface for data and schema access, users and security management.

npmnpm
Version
0.1.0
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

Open Parse

Open Parse = Parse.com + JSON API + koa

The collection of middleware which provides REST API interface for accessing to application data and schema, users and security management.

Built with love to Functional Principles and.. yes, koa.

Basic Usage

The following example has been written with using promised-mongo and koa-router packages.

const router = new Router();
const dataRequired = function *(next) {
  if (typeof this.request.body['data'] === 'object') {
    yield next;
  } else {
    this.throw(400, 'Request data is required');
  }
};

// Users API
const users = {
  dataProvider: pmongo.collection('users')
};
router.post('/users', dataRequired, handleUserSignUp(users));
router.get('/login', handleUserLogin(users));
router.post('/logout', handleUserLogout(users));
router.get('/users/me', handleUserFetch(users));

// Classes API
const classes = {
  dataProvider: pmongo.collection('objects'),
  initialCache: require('./default-objects.json')
};
router.post('/classes/:className', dataRequired, handleObjectCreate(classes));
router.get('/classes/:className', handleObjectsList(classes));
router.get('/classes/:className/:objectId', handleObjectFetch(classes));
router.patch('/classes/:className/:objectId', dataRequired, handleObjectUpdate(classes));
router.delete('/classes/:className/:objectId', handleObjectDelete(classes));

// Schemas API
const schemas = {
  dataProvider: pmongo.collection('schemas')
};
router.get('/schemas/:className', handleSchemaFetch(schemas));

// Connect API end-point to your application
app.use('/api', router);

FAQs

Package last updated on 17 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts