Giter VIP home page Giter VIP logo

hapi-ninja's Introduction

Hapi Ninja

Boilerplate Hapi Web and API Server Example

The Goal:

Create a base boilerplate example showing how easy it is to get started with Hapi as a web server.

The Stack:

Node.js - Because it's fast, easy to get started, and Javascript is awesome. http://nodejs.org/

Hapi - A very well designed server framework that is easy to understand, easy to create your own plugins, scales very well, cache options built in, and more. http://hapijs.com/

Swig - It looks like HTML, it's very fast, great for template inheritance, and allows you to use HTML syntax with the server and with front-end client Javascript includes. http://paularmstrong.github.io/swig/

CSS Framework - None. Choose your own CSS preprocessor and CSS framework.

Gulp - A task runner for your assets, and can do a lot more. The performance is amazing and it is easy to get started. http://gulpjs.com/

Requirements:

Install Node.js by using the big install button on the http://nodejs.org/ homepage.

After Node.js is installed, clone this repo, change cd to this directory, and run npm install

$ git clone https://github.com/poeticninja/hapi-ninja.git
$ cd hapi-ninja
$ npm install

Start the server by running the command:

$ node server

To see any changes you can manually just shutdown and restart the node server. This can be a pain so I use Supervisor to watch for file changes and restart the server https://github.com/isaacs/node-supervisor.

To install run:

$ npm install -g supervisor

To use it run:

$ supervisor -e html,js  server

Now all of your server html and js files are being watched and on change the node server gets restarted automatically.

Production

Before going into production you will want to concatenate and minify your assets. This will increase performance for your user. We will use Gulp for this.

To install run:

npm install -g gulp

Now you can run gulp from the command line and it will run the tasks in the gulpfile.js. The current tasks will minify and optimize your CSS, JS, and Images. If you want more tasks you can go to the Gulp Plugin page. http://gratimax.github.io/search-gulp-plugins/

Plugins

The Hapi plugins that are being used.

Hapi-Named-Routes

Added names to the routes. This allows you to have access to the path in the templates just by using the path.nameofroute variable. https://github.com/poeticninja/hapi-named-routes

Hapi-Assets

Assets are in the ./assets.js file, and your view layer has access based on the node environment. If you are in development (default) you might want to have individual files (js,css). If you are in production you would want the assets combined for user performance. https://github.com/poeticninja/hapi-assets

Hapi-Cache Buster

Client/browser reloads new assets based on package.json version of your application. https://github.com/poeticninja/hapi-cache-buster

Folder Structure

There are two main folders in the stack. The "public" folder for front-end (client side) code, and "server" folder for server side code.

By having the front-end folder and server side folder be specific, it provides for better consistency when changing projects. This way when you change from a full front-end app (Phonegap), to a front-end and server side app you get to keep the same folder structure. Allowing for better consistency with your stack, projects, and tools.

Contributers

See the awesome people!

Credits

Credit goes to all of the open source code that people have made available.

License

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

hapi-ninja's People

Contributors

jeffbski avatar jonlinper avatar nicolasritouet avatar poeticninja avatar tbenade avatar toymachiner62 avatar treshenry avatar

Stargazers

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

Watchers

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

hapi-ninja's Issues

I made a child project.

Hey Saul (+contributors),

Love the project. Found it an amaxing tool. I loved it so much I used it in a new project.

CODE
https://github.com/smaxwellstewart/hapi-dash

DEMO
hapi-dash.smaxwellstewart.com

I joined hapi-ninja to a free template theme and added realtime messaging (Socket.IO) and out-the-box authentication. I used form based authentication for a frontend server and Hawk authentica for an API server.

There are also out-the-box configurable RESTful endpoint for doing basic CRUD of resources into MongoDB.

I am deploying a little differently in terms of starting up the servers, as i use pm2.

I could not of done this without your brilliant project, so thank you. I felt the goal of my stack was too different and a little experimental to try and maintain forks. But I am happy to conribute any stuff of 'hapi-dash' into 'hapi-ninja.

Lastly, if any contributors find any bugs, don't hesitate to open an issue, would be really appreciated.

Open-source love,
Simon

About Models

How can i create models? What ORM do you use?

Integrating Mongoose structure

Hi, I'm using your project structure and find that very helpful. Can you advice me on how would you structure this project adding mongoose integration.
I would need to use models' logic in controllers. Could you help me on that?

exception

Hi,

I've followed the installation on a Windows machine.

I'm getting the following..

C:\boliderplate>node server
Server started at: http://0.0.0.0:3000
140407/093141.856, request, http://0.0.0.0:3000: get / {} 200 (31ms)

events.js:72
throw er; // Unhandled 'error' event
^
Error: EISDIR, write

The server object is passed to the routes module, but is not used

It's not a bug, but might be a typo.

The routes module (server/config/routes.js) is passed the server object (in the main server.js module). However server is not used in routes. That module is just returning the route table (an array with the route configurations).

I believe we should have

   server.route(routeTable);

in server/config/routes.js instead of server.js, no?

No database or notification directories

Your repo looks great. Unfortunately, I'm not able to start the server due to the following message:

Error: Cannot find module './server/database/index.js'

And upon looking at the 'server.js' file, it appears that the file is also requesting the 'index.js' file from the 'notifications' folder, of which also does not appear to exist in your 'hapi-ninja' folder structure. Any suggestions?

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.