marchio-core-app
marchio-core-app
Installation
$ npm init
$ npm install marchio-core-app --save
Introduction
The purpose of this module is to provide core expressjs processing middleware for REST urls in the form of /:model/:id?.
If a matching model name is not found, or an id is expected, a 404 will be returned by the middleware.
Modules
- marchio-core-app
Module
- marchio-core-app-factory
Factory module
marchio-core-app
Module
marchio-core-app-factory
Factory module
Promise
marchio-core-app-factory.create(spec) ⇒ Factory method It takes one spec parameter that must be an object with named parameters
Kind: static method of marchio-core-app-factory
Returns: Promise
- that resolves to {module:marchio-core-app}
Param | Type | Description |
---|---|---|
spec | Object |
Named parameters object |
spec.model | Object |
Model definition |
[spec.use] | Object |
Middleware to be passed on to app.use |
[spec.numeric] | boolean |
If true (default), id parameter is converted to a number |
Example (Usage example)
"use strict"; var killable = factory = ; var _modelName = 'coretest'; var _testModel = name: _modelName fields: email: type: String required: true status: type: String required: true default: "NEW" ; factory ;
Testing
To test, go to the root folder and type (sans $):
$ npm test
Repo(s)
Contributing
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
Version History
Version 0.1.4
- Added numeric flag to create method
- If numeric is set to false, the id parameter will be treated like a string
Version 0.1.3
- Refactored test cases and doc example
Version 0.1.2
- Fixed version history
Version 0.1.1
- initial release