This repo is an easy-to-use npm template to create modules for accelerated.api. Start by simply cloning this repo and updating your git remote origin:
-
Clone the template to your directoy with
git clone https://github.com/haseebnqureshi/accelerated.api.module-template.git ./{YOUR_DIRECTORY}
; -
Remove the existing project's git origin with
git remote remove origin
; -
Add your git origin with
git remote add origin {YOUR_REPOSITORY_URL}
; -
And then push the codebase up to your git repo with
git push -u origin master
.
You're ready for some changes! Then in your new directory and git repo, do the following:
-
Change your
moduleKey
andmoduleName
in index.js. (moduleKey
is a key that uniquely identies your module in the context of your app.) -
Update your
package.json
with your information and module information. -
Now actually create your module by utilizing the three CommonJS modules in this repo,
middleware
,model
, androute
. Please note the structure and direct injected variables in each CommonJS module and what each is returning. -
Run
npm publish
in your command line to publish directly onto npm, and viola! You've got a npm packaged module for accelerated.api.
Okay, so how do you use this module in your accelerated.api project? Here's an example:
var api = require('accelerated.api');
var example = require('acceleratd.api.module');
api.useMiddlewares([
[example.key, example.middleware]
]);
api.useModels([
[example.key, example.model]
]);
api.useRoutes([
[example.key, example.route]
]);
api.run();