Giter Club home page Giter Club logo

hapi-api-boilerplate's Introduction

Hapi Chairo Api Boilerplate

DEPRECATION NOTICE

This project is no longer mantained.
Use generator-hapi-api-stack instead.

Table of Contents

Usage

Run npm install as usual

npm run dev will run the server with config.dev.js settings

npm run staging will run the server with config.staging.js settings

npm run prod will run the server with config.prod.js settings

Plugins loading and registration

You can easily customize your Hapi server by adding the plugins you need in /server.js manifest file or in /lib/index.js.

Jobs, Routes, Auth, Models and Services loading

Everything has been setup in order to avoid the need to write code to add new components to the server. Anyway, since this is a boilerplate and the loading process cannot be completely abstracted, you'll probably need to tweak various things around if you plan to use different packages for models, jobs, services, etc...

Auth Strategies

You can add your authentication strategies in /lib/config/auth.js and they will be registered automatically. The default authentication strategy is set in /lib/index.js.

Routes

Adding a new route is a two step operation:

  1. Create a route as /lib/routes/routename.js
  2. Add routename into /lib/config/routes.js

Prefix

Every registered route is prefixed by a prefix and a version (/api/v1 is the default). API_PREFIXand API_VERSION are defined in /lib/config/routes.js.

Models

To add a new model, just create a new filename into /lib/models/ and it will be loaded automatically.

Jobs

Adding a new job is a two step operation:

  1. Create a job into /lib/jobs/jobname.js
  2. Add jobname into /lib/config/jobs.js

Services

Adding a new service is a two step operation:

  1. Create a service into /lib/jobs/servicename.js
  2. Add servicename into /lib/config/services.js

Project Structure

hapi-chairo-api-boilerplate
├── lib
│   ├── boot      # loader utils
│   ├── config    # configs
│   ├── jobs      # jobs
│   ├── models    # models
│   ├── services  # services
│   ├── routes    # routes
│   └── index.js  # plugins loading and registrations
│
├── test
│   ├── example-test.js 
│
├── logs 
│
├── server.js # server composition
├── config.js # setup ENV config
├── config.dev.js
├── config.staging.js
├── config.prod.js
├── package.json
└── README.md

Packages Docs

Hapi

  • Hapi | Server Framework
  • Glue | Server Composer
  • Poop | Logs uncaught exceptions
  • Boom | HTTP errors
  • Joi | Object Schema validation

Models

Services

  • Seneca | Microservices Toolkit
  • Chairo | SenecaJS/Hapi integration

Jobs

Tests

Utils

TODO

  • Better logs handling
  • API Docs support

hapi-api-boilerplate's People

Contributors

franzip avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

shotu bonnak

hapi-api-boilerplate's Issues

Setup MySql-sequelize.

Hi, I'm beginner.

Please help me to setup MySql-sequelize with this project follow your philosophy (boilerplate,structure,config...)

Thanks and Regards,

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.