Giter Club home page Giter Club logo

node-hapi-starter-kit's Introduction

Node-Hapi-Starter-Kit

This boilerplate is based on Nodejs with Hapi server framework. It is complete with a sample running test.

This is created primarily to encourage using Docker while Development. Use one of the docker integrations (mysql or postgres) below to proceed. If one is determined otherwise please make the config changes in ./config/config.js file

Eg:

'local_mysql': {
        'username': 'root',
        'password': 'password',
        'database': 'article',
        'host': 'localhost',
        'dialect': 'mysql',
        seederStorage: 'sequelize',
        operatorsAliases: false
    },

Then do npm install to start up.

To start the server do NODE_ENV=local_mysql npm start (This will start the server at port 5000).

You can now hit the test API at localhost:5000/api/hello/2

It comes with a Hapi-Swagger (https://github.com/glennjones/hapi-swagger) package for API Documentation. Demo? After running the server open the link localhost:5000/documentation

Docker Integration

  1. docker-compose up -d

  2. Any command available in package.json can be run directly. For eg. to drop the database run docker-compose run app npm run drop-localPSQL. Similarly migrate-localPSQL.

  3. To see logs of any of these containers first choose the container (app or db).
    a. Do docker-compose ps to list all the containers for THIS particular project. b. Choose the container name. c. docker logs -ft --details --since 5m <Container_name> . See docker logs -h for more info.

  4. Even though hot reloading will work , it be possible that you need to restart your server, or build your containers again using a different configs. Do the steps below to rebuild: a. docker-compose down b. To build again do docker-compose up --build -d

PostgresSQL is working fine:

  1. docker-compose up --build -d
  2. docker-compose run app npm run migrate-localPSQL
  3. Open http://localhost:5000/api/hello/2

MySQL is working fine: (Uncomment mysql specific lines in docker-compose.yml file at 3 places and comment postgres specific lines)

  1. docker-compose up --build -d
  2. docker-compose run app npm run migrate-localMSQL
  3. Open http://localhost:5000/api/hello/2

Corrupt mysql or postgres database [Delete docker volume]:

[Warning: This will remove all the unclaimed volumes in docker. Please prune the specific volume of your application only!]

  1. docker-compose down
  2. docker volume prune

node-hapi-starter-kit's People

Contributors

diwakar-s-maurya avatar rahuljain1311 avatar rjsolacemck avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

chalermporn

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.