Skip to content

Commit

Permalink
clean code|add restify plugin to store
Browse files Browse the repository at this point in the history
  • Loading branch information
Dugnist committed Jun 19, 2018
1 parent 098ebf2 commit 01ed098
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
6 changes: 2 additions & 4 deletions README.md
Expand Up @@ -110,22 +110,20 @@ Install extension <a href='https://chrome.google.com/webstore/detail/nodejs-v8-i

## What's new?

You can check our <a href="https://github.com/Dugnist/jsberry/blob/master/ROADMAP.md">ROADMAP</a> and propose new features.
You can check our <a href="https://github.com/Dugnist/jsberry/blob/master/ROADMAP.md" target="_blank">ROADMAP</a> and propose new features.

## Community support

For general help using JSBerry, please refer to the official <a href="https://dugnist.gitbooks.io/jsberry">documentation</a>. For additional help, you can use ask question here:
For general help using JSBerry, please refer to the official <a href="https://dugnist.gitbooks.io/jsberry" target="_blank">documentation</a>. For additional help, you can use ask question here:

- <a href="https://t.me/joinchat/Ell7tkiTmlo8WvGgRu2aoA">Telegram</a> (realtime support)
- <a href="https://www.facebook.com/messages/t/Dugnist">Facebook</a>

## Author

**Dugnist Alexey**

- <https://www.linkedin.com/in/Dugnist>
- <http://github.com/Dugnist>
- <https://www.facebook.com/Dugnist>


## Copyright and license
Expand Down
10 changes: 5 additions & 5 deletions ROADMAP.md
Expand Up @@ -4,7 +4,7 @@

This document could be influenced by the community feedback, security issues, stability, future needs, etc.

<a href="https://favro.com/organization/9039a67d00a837f22b655a13/e10dfa4c8d6be999b74f9301">Live task management</a>
<a href="https://favro.com/organization/9039a67d00a837f22b655a13/e10dfa4c8d6be999b74f9301" target="_blank">Live task management</a>

### alpha

Expand All @@ -15,11 +15,11 @@ This document could be influenced by the community feedback, security issues, st
* ~~Mediator with ACTIONS.~~
* ~~ROUTER with routes and middlewares support.~~
* ~~Add "express" REST plugin.~~
* ~~Add "mongoose" plugin.~~
* ~~Add <a href="https://github.com/Dugnist/jsberry/blob/master/STORE.md">"mongoose" plugin</a>.~~
* ~~vulnerabilities checkers: "nsp" and "snyk".~~
* ~~Update middlewares, add layers.~~
* ~~Add "koa" REST plugin.~~
* ~~Add "twillio" sms plugin.~~
* ~~Add <a href="https://github.com/Dugnist/jsberry/blob/master/STORE.md">"koa" REST plugin</a>.~~
* ~~Add <a href="https://github.com/Dugnist/jsberry/blob/master/STORE.md">"twillio" sms plugin</a>.~~
* ~~v8 debug inspector.~~

`jsberry@alpha.0.2`
Expand All @@ -28,7 +28,7 @@ This document could be influenced by the community feedback, security issues, st
* ~~Add husky, lint staged to check errors at precommit~~.
* ~~Authorization middleware~~.
* ~~Add "websockets" plugin~~.
* Add "restify" REST plugin.
* ~~Add <a href="https://github.com/Dugnist/jsberry/blob/master/STORE.md">"restify" REST plugin</a>.~~
* Remove default logger, add "pino" logger plugin.
* Error handler module.
* Validation middleware.
Expand Down
1 change: 1 addition & 0 deletions STORE.md
Expand Up @@ -9,6 +9,7 @@ Curated list of jsberry modules and plugins.
### API

- <a href="https://github.com/Dugnist/jsberry-koa-api">Koa API</a>
- <a href="https://github.com/Dugnist/jsberry-restify-api">Restify API</a>

### Messages

Expand Down
23 changes: 13 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/modules/users/middlewares/auth.middleware.js
Expand Up @@ -10,9 +10,11 @@ const USER = require('../mongo-schemas/user');
// set path details to error output
const currentPath = __dirname.split('/').slice(-3).join('/');

// KOA test wrapper! Not for production! Use ctx instead (req, res)
// if (!next) res.send = (q) => req.body = JSON.stringify(q);
module.exports = (ACTIONS) => async(req, res, next) => {
try {
if (req.headers.authorization) throw new Error('Empty token!');
if (!req.headers.authorization) throw new Error('Empty token!');
const token = req.headers.authorization.split('Bearer ')[1] || '';
const user = await ACTIONS // required database plugin!!!
.send('database.read', { model: USER.model, payload: { token } });
Expand Down
1 change: 0 additions & 1 deletion src/plugins/graphql_api/index.js
Expand Up @@ -40,7 +40,6 @@ module.exports = ({ ACTIONS, ROUTER, show }) => {
});

const graphqlMiddleware = (req, res, next) => {
console.log(req.url);
if (req.url.indexOf('/graphql') !== -1) {
graphqlHTTP({ schema, graphiql: true })(req, res);
} else {
Expand Down

0 comments on commit 01ed098

Please sign in to comment.