Git Product home page Git Product logo

keystone-rest-api's Introduction

Keystone Rest API

This extension for Keystone is intended to create a REST API very easy. Also is prepared to output the Documentation for the created API. The Documentation is based on API Blueprint ( Format 1A8 ).

Features

  • Automatic REST API
  • API Documentataion

Documentation

http://sarriaroman.github.io/Keystone-Rest-API

Options

  • Model

    • rest {Boolean}

    • restOptions {String} 'list show create update delete'

    • restDescription {String}

  • List Object

    • restHooks {Object}
{
    list: [listMiddleware],
    show: [showMiddleware],
    create: [createMiddleware],
    update: [updateMiddleware],
	delete: [deleteMiddleware]
}
  • Fields
    • restSelected {Boolean}

    • restEditable {Boolean}

Usage

    var keystone = require('keystone'),
		fs = require('fs'),
      	Types = keystone.Field.Types,
      	keystoneRestApi = require('keystone-rest-api');

    var User = new keystone.List('User', {
		rest: true,
		restOptions: 'list show create update delete'
	});

    User.add({
      	name: { type: Types.Name, required: true, index: true },
      	password: { type: Types.Password, initial: true, required: false, restSelected: false },
      	token: { type: String, restEditable: false }
    });
	
	User.restHooks = {
      	list: [listMiddleware],
      	show: [showMiddleware],
		create: [createMiddleware],
      	update: [updateMiddleware],
      	delete: [deleteMiddleware]
    };

    User.register();

    // Make sure keystone is initialized and started before
    // calling createRest

    keystone.init(config);

    // Add routes with Keystone
    keystoneRestApi.createRest(keystone, {
		apiRoot: '/api/'
	});

    keystone.start();
	
	// Create Documentation and write it to a file
	fs.writeFileSync('api.md', keystoneRestApi.apiDocs(), 'UTF-8');

Changelog

0.9.7.1

  • Added ignoreNoEdit to Create to avoid awful errors for now

0.9.7

  • restDescription field to specify the Description of the REST Endpoint
  • Use of keystone Name to create the Header of the Blueprint API Document

0.9.6

  • Added attributes to Model Definition in the Documentation
  • Added Support for Select Field on API Generation
  • Added support for Required in Documentation

0.9.5

  • Added support for UpdateHandler

TODO

  • The "update" and "create" method must use the Keystone UpdateHandler (Done)
  • Implement a way to set Options for UpdateHandler
restOptions: {
	ignoreNoedit: true
}
  • New Tests based on the changes.

Authors

keystone-rest-api's People

Contributors

sarriaroman avatar dminones avatar unjapones 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.