Skip to content
Sean Kennedy edited this page Jan 26, 2016 · 4 revisions

Here's an example of a typical directory structure.

├── [your_project_name]/
│   ├── index.js <-- optional Main script
│   ├── package.json
|   ├── config/
│   │   ├── default.json
│   ├── handlers/
│   ├── services/
│   ├── middleware/
│   ├── swagger/

Here's what happens when you start the BlueOak server for this project:

BleuOak server startup algorithm: from files to function

(In text:

  1. Load from config/, overlaying in this order:
  • default.json
  • ${NODE_ENV}.json
  • <stanza-name>.json
  1. Build dependency tree based on the init() functions for modules in handlers/, middleware/ and services/
  • Resolve built-in services, e.g.: ‘cache’, ‘config’, ‘logger’, ‘monitor’
  • Search for unresolved service dependencies in node_modules/
  1. Call the init() functions per the dependency tree

  2. Load spec definition(s) from swagger/

  3. Initialize the swagger validator with the spec

  4. “Wire” the swagger validator to the associated handler (x-handler property in the swagger spec)

  5. Expose the swagger API to the network

)

Clone this wiki locally