All Projects → metoikos → hapi-moon

metoikos / hapi-moon

Licence: MIT license
Hassle-free and production ready hapi.js Server boilerplate

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to hapi-moon

Crashlyzer
Crash viewer web application for displaying the crashes reported by rn-crash-reporter components from React Native mobile applications.
Stars: ✭ 59 (+156.52%)
Mutual labels:  hapi, hapijs
sapper-authentication-demo
A demonstration of Auth with Sapper + JWT + Server Side Rendering + RBAC
Stars: ✭ 102 (+343.48%)
Mutual labels:  hapi, hapijs
Rest Hapi
🚀 A RESTful API generator for Node.js
Stars: ✭ 1,102 (+4691.3%)
Mutual labels:  hapi, mongoose
hano-graphql
GraphQL, Hapi and Node Project For Scaleable Apps.
Stars: ✭ 13 (-43.48%)
Mutual labels:  mongoose, hapijs
hapi-now-auth
Hapi token auth for bearer and jwt
Stars: ✭ 43 (+86.96%)
Mutual labels:  hapi, hapijs
Appy Backend
A user system to bootstrap your app.
Stars: ✭ 96 (+317.39%)
Mutual labels:  hapi, mongoose
good-sentry
Sentry broadcasting for good process monitor
Stars: ✭ 15 (-34.78%)
Mutual labels:  hapi, hapijs
nodejs-tutorials-hapi
Examples for the hapi tutorial series within the Future Studio University
Stars: ✭ 70 (+204.35%)
Mutual labels:  hapi, hapijs
hapi-good-winston
A good reporter to send and log events with winston
Stars: ✭ 21 (-8.7%)
Mutual labels:  hapi, hapijs
hapi-plugin-mysql
Hapi plugin for MySQL
Stars: ✭ 17 (-26.09%)
Mutual labels:  hapi, hapijs
typesafe-hapi
Typechecking for HapiJS based on Joi schemas!
Stars: ✭ 21 (-8.7%)
Mutual labels:  hapi, hapijs
hapi-cli
CLI to build API with Hapi, mongodb and mongoose. Work with Hapi V17.
Stars: ✭ 36 (+56.52%)
Mutual labels:  hapi, hapijs
wily
Build Node.js APIs from the command line (Dead Project 😵)
Stars: ✭ 14 (-39.13%)
Mutual labels:  hapi, mongoose
querymen
Querystring parser middleware for MongoDB, Express and Nodejs (MEN)
Stars: ✭ 128 (+456.52%)
Mutual labels:  mongoose
aircnc
☕ Airbnb like (Air Coffee & Code) to booking spots for developers using ReactJS, React Native, Node.js and more.
Stars: ✭ 37 (+60.87%)
Mutual labels:  mongoose
react-node-twitter-login
Demo application that shows how to enable Twitter login with React on frontend and Node.js/Express on backend
Stars: ✭ 34 (+47.83%)
Mutual labels:  mongoose
react-express-jwt
Example NodeJS, Express, Mongoose, React app with JWT auth for beginners WITHOUT redux.
Stars: ✭ 51 (+121.74%)
Mutual labels:  mongoose
koa-server
🗄️ GraphQL Back-end Server with Relay, Koa, MongoDB and Mongoose
Stars: ✭ 31 (+34.78%)
Mutual labels:  mongoose
BEW-1.3-Server-Side-Architectures-and-Frameworks
🔐 Build on knowledge of Resourceful and RESTful patterns and dive deep into the Node and Express ecosystem.
Stars: ✭ 19 (-17.39%)
Mutual labels:  mongoose
rethinkdb-express-api-boilerplate
rethinkdb express api boilerplate
Stars: ✭ 23 (+0%)
Mutual labels:  api-boilerplate

Simple yet powerful hassle-free and production ready hapi.js Server boilerplate

Build Status

Hapi-Moon provides a ready to go server boilerplate for hapi applications. All you need to do is install dependencies and run npm start command.

With Hapi-Moon you'll have:

  • Production ready docker setup
  • Multi environment configs (dev/prod/test with config)
  • MongoDB (Mongoose) Models
  • Authentication
  • Rest API Support
  • CSRF validation crumb
  • Cookie Management with yar (stores sessions in Redis backend)
  • View Render Support (nunjucks)
  • Cache (Redis with catbox-redis)

Usage

With Docker

git clone https://github.com/metoikos/hapi-moon.git
cd hapi-moon
docker-compose up

It will expose port 3009 for your hapi-moon application. You can change the port and other details from config/default.json file.

Standart NPM

git clone https://github.com/metoikos/hapi-moon.git
cd hapi-moon
npm install
npm test
npm start

Please visit routes and controllers folders to see how to define a route and controller.

Rest Api Usage

In order to use this boilerplate as REST API, you need to send "X-CSRF-Token" information in the header. Otherwise, your request won't be allowed by the server.

Also you need to remove plugins.crumb block from your handler.

    plugins: {
        crumb: {
            restful: false
        }
    }

Let's say you want to implement authentication to your SPA then your auth/login handler would be like this.

exports.login = {
    auth: false,
    validate: {
        payload: validators.login
    },    
    description: 'sign in user to system',
    handler: async (request, h) => {
        const result = await User.login(request.payload.email, request.payload.password);
        if (result) {
            request.yar.set('auth', result.apiData());
            return {status: true, result: result.apiData()};
        }

        return {error: 'Invalid email or password'}
    }
};

To read more about this please refer to crumb documentation.

Production deployment

To use this application under production, first, create a file named production.json under the config folder. Then update the necessary variables in it.

For details about multi-environment config, please refer to config.

To start your production application, you can use any of the below definitions.

Standart Way

Install modules and then start the application

NODE_ENV=production NODE_CONFIG_DIR=./config npm start

Docker Way

Just edit your production.json file and make sure that you have the correct settings in your docker-compose.yml file, and then start your application.

docker-compose up -d

PM2

PM2 is a process manager for node and many other languages.

Install PM2

npm install pm2@latest -g
pm2 startOrRestart pm2-startup.json

Please visit PM2 documentation for other details.

PM2 & Docker

You can use PM2 with Docker as well. You will find the instructions inside the Dockerfile. Just make sure that you set the correct environment and config files.

Create User

Run npm run add-user then follow instructions

asciicast

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].