generator-hapi-restful-version v1.0.3
generator-hapi-restful-version
This is a yeoman generator utility module to generate a sample hapi api service project.
Note: This is tailored for our project requirements.
Installation
Install the following two packages globally as below.
$ npm install yo -g
$ npm install retire -g
$ npm install gulp -g
$ npm install generator-hapi-restful-version -g
Usage:
1) To generate the skeleton of a Hapi REST API service node project , use the following command
$ yo hapi-restful-version:hapiApiService
2) To generate a Hapi REST API service with a new version , use the following command
$ yo hapi-restful-version:hapiApiVersion
3) To generate a Hapi REST API service with a new module , use the following command
$ yo hapi-restful-version:hapiApiModule
4) After the successful creation of new module eg. auth
,
goto app-router.js
file in the folder path app/register
and add the following line as below as highlighted in red in the screenshot.
const {authRouter} = require(",,/modules/auth/auth-router");
Inside appRouter function add the following line.
appRouter(server);
####Note: any project related config values can be initialized in config\app.json
To get the configuration values in the project , use as below
eg . global.config.app.apiPort
if the new config file is added in the name of user.json into config directory as config\user.json
, then use as below eg . global.config.user.name