Skip to content

Commit

Permalink
update README|fix mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dugnist committed Jul 7, 2018
1 parent d248055 commit f1cb6d4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,41 @@ If you wanna install another framework instead of "express" - you can check <a h
Also, you can check `src/core/config/index.js`
to set key `"framework"` to your framework name (default "express").

## How to use

After installing you can create any your own module in "src/modules" directory or any your own plugin in "src/plugins" directory.
For example, we can create a plugin for making outside requests from the server using the npm module "request".

- Install node module "request-promise" using `npm i request-promise`.
- Create a directory "request" in "src/plugins".
- Create file "index.js" in "request" directory.
- Paste this code to "index.js" for create plugin wrapper.

```
const request = require('request-promise');
module.exports = ({ ACTIONS }) => {
// plugin code...
});
```

- Create an ACTION which will send outside request. Paste this code instead "// plugin code..."

```
ACTIONS.on('request.send', ({ url = 'http://www.google.com' }) => {
return request(url);
});
```

After that, you need to connect your module/plugin to application "core":

- Go to "src/plugins/index.js".
- Add this line to top: `const Request = require('./request');`
- Add your plugin variable Request to array "PLUGINS".

Now, you can call `ACTION.send('request.send', { url: 'example.com' });` from any other module/plugin and it will return promised site response.


## List Of Scripts

- `npm start` - run application with development mode
Expand Down
2 changes: 1 addition & 1 deletion src/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ global.APP = APP;

/**
****************************************
* Make sure we are running node 7.6+ *
* Make sure we are running node 8.6+ *
****************************************
*/

Expand Down
6 changes: 4 additions & 2 deletions src/modules/users/middlewares/validation.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ module.exports = (ACTIONS) => async(req, res, next) => {
schema: validation[currentRoute.validation.schema],
payload: parameters,
});
// const result = validation[currentRoute.validation.schema](parameters);

if (result.error && result.error.message) {
throw new Error(result.error.message);
Expand Down Expand Up @@ -60,7 +59,10 @@ module.exports = (ACTIONS) => async(req, res, next) => {
// .reduce((prev, next) => ({ ...prev, ...next }));
//
// // Get validation schema by name from config
// const result = validation[currentRoute.validation.schema](parameters);
// const result = await ACTIONS.send('validate.schema', {
// schema: validation[currentRoute.validation.schema],
// payload: parameters,
// });
//
// if (result.error && result.error.message) {
// throw new Error(result.error.message);
Expand Down

0 comments on commit f1cb6d4

Please sign in to comment.