Code Monkey home page Code Monkey logo

jolly's Introduction

Jolly

Production ready boilerplate for hapiJS

Technology

  • Hapi - Server side framework
  • Handlebar - HTML templating engine
  • Mongoose - Mongo database ORM
  • SASS - CSS preprocessor
  • Gulp - Javascript tasks automation
  • WebPack - Asset pipeline

Note: For a detailed list of the toolsets used in jolly, please refer to package.json.

Application Structure

Let's take a tour of the app.

|
| -- app
|   |-- controllers        // Controllers are organised by module names
|   |   |-- <module_name>  // Each controller defines config and handler for that route.
|   |
|   |-- helpers            // Helper functions used across application
|   |-- models             // All mongoose models are defined here
|   |-- routes             // All app routes are defined here
|   |   |-- <route_plugin> // Route module is a hapi plugin and can be toggled from config/manifest.js
|   |
|   `-- templates          // All server-rendered handlebar templates, partials and helpers
|       |-- <module_name>  // Templates are organised by module names.
|   
|-- assets                 // Contains all static resources 
|   |-- fonts              // Fonts used in application
|   |-- images             // Images used in application
|   |-- misc               // Misc resources used in application
|   |-- scripts            // Client javscripts files which are then packed by webpack
|   |-- styles             // All SASS stylesheets
|   |   |-- <module_name>  // Styles are organised by module names. 
|   
|-- config                 // Contains all app configurations
|   |-- assets.js          // Assets configuration file
|   |-- config.js          // Application configuration file which stores all passwords etc. (gitignore).
|   |-- manifest.js        // App manifest file listing all plugins and load order. 
|   |-- meta.js            // App metadata file. 
|   
|-- lib                    // Core application lib/plugins 
|-- tasks                  // Contains all gulp tasks 
|-- tests                  // Code tests
|
|-- gulpfile.js            // Gulp entry file 
|-- index.js               // Application starting point
|-- package.js             // Package configuration file
|-- server.js              // Main server file

Code

We're using semi-colons and comma-last. No rhyme or reason; and some of the hapi code convention guidelines. All client-side js code is also in commonJS pattern packs using webpack. Check out .editorconfig, .jsbeautifyrc, .eslintrc for additional code conventions used.

Running the server locally

  • Install node, npm
  • Rename config/config.example.js to config/config.js folder.
  • Run these commands
# Install deps
$ npm install

# Run the node server
$ npm start

# > [email protected] start /Users/ravisuhag/Batcave/Workspace/ronin/Dev/jolly
# > gulp
# 
# [16:48:55] Using gulpfile ~/Batcave/Workspace/ronin/Dev/jolly/gulpfile.js
# [16:48:55] Starting 'fonts'...
# [16:48:56] Starting 'images'...
# [16:48:56] Starting 'misc'...
# [16:48:56] Starting 'styles'...
# [16:48:56] Finished 'styles' after 5.49 ms
# [16:48:56] Starting 'webpack'...
# [16:48:56] Finished 'webpack' after 73 ms
# [16:48:56] Starting 'lint'...
# [16:48:56] Starting 'nodemon'...
# [16:48:56] Finished 'nodemon' after 1.99 ms
# [16:48:56] [nodemon] v1.4.1
# [16:48:56] [nodemon] to restart at any time, enter `rs`
# [16:48:56] [nodemon] watching: *.*
# [16:48:56] [nodemon] starting `node server.js`
# [16:48:57] Finished 'images' after 1.98 s
# [16:48:57] Finished 'misc' after 1.98 s
# Server is listening on 8000

The server should be running at localhost:8000.

Running tests

Lab is part of the hapi.js toolset and what we use to write all of our tests.

$ npm test
# > [email protected] test /Users/ravisuhag/Batcave/Workspace/ronin/Dev/jolly
# > node node_modules/lab/bin/lab -a code -t 100

# ..............

# 6 tests complete
# Test duration: 1370 ms
# No global variable leaks detected
# Coverage: 100.00%

Contributers

See the awesome people!

jolly's People

Contributors

akarshsatija avatar ravisuhag avatar turtledev avatar tutv 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

Watchers

 avatar

jolly's Issues

the dev task points to index.css instead of index-<revno>.css

Running npm run dev with an updated package.json (see #3), the index page fails to render properly as it tries to load index.css, instead of index-<revno>.css. I thought on adding a static file handler for dev mode that can read rev-manifest.json in dev mode, but it seems to be a rather hacky solution. Is there a better way to fix this?

[feature request] use revision number(s) for all static assets?

Only CSS files get revision in the current snapshot. However, other assets (especially JS) could also make use of it.

The reason I ask is because browsers can then cache your assets (by setting expiry headers), thereby reducing load times considerably.

We could probably also extend this to images too.

Error on running first time

WARNING: vision failed to load helper '/var/devesh/NODE_2016/jolly/app/templates/helpers/m.js': Cannot find module '../../../.build/rev-manifest' Server started @ http://devesh:8000 Mongo Database connected Debug: internal, implementation, error Error: Failed to encode cookie (session) value: Password string too short (min 32 characters required) at /var/devesh/NODE_2016/jolly/node_modules/statehood/lib/index.js:436:34 at /var/devesh/NODE_2016/jolly/node_modules/statehood/node_modules/hoek/lib/index.js:854:22 at _combinedTickCallback (internal/process/next_tick.js:67:7) at process._tickDomainCallback (internal/process/next_tick.js:122:9)

gulp rev is missing

After updating the package.json file (similarly to pull request #3) I've tried to run gulp build, but it failed with

Task 'rev' is not in your gulpfile

Issue in mongodb

Not able to save the data in mongodb.. What could be the possible reason for this issue. The output is showing the data is saved successfully but if I check in mongodb no data is present.

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.