0.0.13 • Published 10 years ago

generator-hapi-rest-api v0.0.13

Weekly downloads
6
License
MIT
Repository
github
Last release
10 years ago

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? (git@github.com:<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

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago