Giter Site home page Giter Site logo

sarriaroman / keystone-rest-api Goto Github PK

View Code? Open in Web Editor NEW
19.0 3.0 6.0 5.26 MB

Creates a RESTful API based on Keystone Lists. The extension is also prepared to create the Documentation of the created API

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

JavaScript 100.00%

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);
    keystone.start();

    // Add routes with Keystone
    keystoneRestApi.createRest(keystone, {
		apiRoot: '/api/v1/'
	});
	
	// 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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

keystone-rest-api's Issues

Hola Roman

Estoy realizando con fin tu ejemplo en una pagina creada con keystone la pagina solo muestra un nombre completo al integarar con el KeystoneRestApi para consultar nombre por webservice me genera el siguiente error

keystone.init(config);
^

ReferenceError: config is not defined
at Object. (/home/eeb2/keystone.js:58:16)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.runMain (module.js:575:10)
at run (bootstrap_node.js:352:7)
at startup (bootstrap_node.js:144:9)
at bootstrap_node.js:467:3

en la documentacion no viene que nes este objeto config, me podrias orientar

amazing api listing

it is a great listing api. are there any ways that i could add the filter variables just like the current keystone backend into the resthook object?

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.