Skip to content

Instantly share code, notes, and snippets.

@shahzadns
Last active January 23, 2017 19:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shahzadns/fe736b02d5149b832737a055422b2f0e to your computer and use it in GitHub Desktop.
Save shahzadns/fe736b02d5149b832737a055422b2f0e to your computer and use it in GitHub Desktop.
This gist proposes an enhanced CommonJS module declaration pattern for NodeJS.
/*
Date: Jan 19 2017
title: NodeJS enhanced CJS module pattern
author: Shahzad Nawaz
email: shahzadscs@gmail.com
Description:
This gist proposes an enhanced CommonJS module declaration pattern for nodeJS/express modules.
*/
//(all core imports,requires should be listed here. e.g "fs", etc)
/*core modules*/
//...
//(all external imports,requires should be listed here. e.g "express", etc)
/*external modules*/
//...
//(all module-scoped local vars, lets, should be listed here.)
/*locals*/
//...
//(any initialization(s) should be written here.)
/*initialization*/
//...
//(all routes, or anything similar should be listed together, along with ref to their handlers here)
/*routes list*/
//...
//(all module exports(first indirect ones (from another module), then direct ones) should be listed here.)
/*exports*/
//...
//(all handlers (routes, utils) should be listed here.)
/*functions declarations*/
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment