Giter Club home page Giter Club logo

generator-hapi-rest-api's Introduction

Hapi REST API generator (generator-hapi-rest-api) Build Status

Yeoman generator

This generator generates a simple REST api using hapijs framework. Just follow the generator instructions and create your own api.

API setup

  • Framework: Hapijs
  • Database: Mongodb via mongoose
  • Documenation: swagger via hapi-swagger plugin

API structure

  • Server definition: /lib/index.js (Plugins, ports, etc.)
  • Version 1 of api as plugin: /lib/v1/index.js (routes, params, validations, etc.)
  • Joi validation schema for post and put route: /lib/v1/schemas/modelSchema.js
  • Mongoose model: /lib/v1/models/modelModel.js
  • Request handler: /lib/v1/handlers/*.js (get, post, put, delete handlers)

Getting started (sample address api):

npm install -g generator-hapi-rest-api

mkdir address_rest_api
cd address_rest_api

yo hapi-rest-api

? Would is the name of your resource? (address) 
? What are the fields of the resource? (street:string,street_number:number,postcode:number,city:string,is_deleted:bool) 
? On what port do you want this api to listen? (8500) 
? What is the name of your project? (address_rest_api) 
? What is the name of the db collection? (addresses) 
? What is the url of your db instance? (localhost:27017) 
? What is the git url of this project? ([email protected]:<github_user>/<project_name>) 

node index

go to http://localhost:8500/documentation

What's next?

  • todo: add acceptance tests
  • todo: use npm config module
  • todo: add authentication
  • add subgenerators for new routes, models, schemas, ...

License

MIT

generator-hapi-rest-api's People

Contributors

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