Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
evheniy committed Oct 29, 2017
1 parent cb2f651 commit c8a94b2
Show file tree
Hide file tree
Showing 9 changed files with 225 additions and 230 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

charset = utf-8

indent_style = space
indent_size = 2
11 changes: 2 additions & 9 deletions .eslintrc
@@ -1,17 +1,10 @@
{
"extends": "eslint",
"extends": "airbnb-base",
"env": {
"es6": true,
"node": true,
"mocha": true
},
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module"
},
"rules": {
"indent": ["error", 4, {"SwitchCase": 1}],
"quotes": ["error", "single"],
"no-unused-expressions": 0
}
}
}
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -2,4 +2,5 @@ coverage
.idea
npm-debug.log
node_modules
.DS_Store
.DS_Store
package-lock.json
6 changes: 3 additions & 3 deletions .travis.yml
@@ -1,8 +1,8 @@
language: node_js
node_js:
- "7.6"
- "7.7"
- "7"
- "8"
script:
- npm run lint
- npm run test
- npm run report
- npm run report
43 changes: 11 additions & 32 deletions README.md
Expand Up @@ -26,53 +26,32 @@ It helps run express middleware on YEPS

## How to use

app.js

const http = require('http');
const path = require('path');
const App = require('yeps');
const app = new App();
const error = require('yeps-error');
const Router = require('yeps-router');
const router = new Router();

const server = require('yeps-server');
const wrapper = require('yeps-express-wrapper');

const app = new App();
const router = new Router();

// express middleware
const bodyParser = require('body-parser');
const favicon = require('serve-favicon');
const path = require('path');


app.then(wrapper(favicon(path.join(__dirname, 'public', 'favicon.ico'))));
app.all([
error(),
wrapper(bodyParser.json()),
]);

app.then(error());

router.get('/').then(async ctx => {
console.log(ctx.req.body);
ctx.res.writeHead(200);
ctx.res.statusCode = 200;
ctx.res.end('test');
});

app.then(router.resolve());

server.createHttpServer(app);

http
.createServer(app.resolve())
.listen(parseInt(process.env.PORT || '3000', 10));

And

node app.js

## Links

* [yeps](https://github.com/evheniy/yeps) - YEPS
* [yeps-router](https://github.com/evheniy/yeps-router) - YEPS promise based router
* [yeps-error](https://github.com/evheniy/yeps-error) - YEPS 404/500 error handler
* [yeps-redis](https://github.com/evheniy/yeps-redis) - YEPS promise based redis client
* [yeps-logger](https://github.com/evheniy/yeps-logger) - YEPS Async logger
* [yeps-boilerplate](https://github.com/evheniy/yeps-boilerplate) - YEPS app boilerplate
* [yeps-promisify](https://github.com/evheniy/yeps-promisify) - YEPS kernel
* [yeps-benchmark](https://github.com/evheniy/yeps-benchmark) - performance comparison koa2, express and node http
* [express](https://github.com/expressjs/express)
#### [YEPS documentation](http://yeps.info/)yeps-bodyparser](https://github.com/evheniy/yeps-bodyparser) - YEPS body parser
4 changes: 2 additions & 2 deletions appveyor.yml
@@ -1,6 +1,6 @@
environment:
matrix:
- nodejs_version: "7.7"
- nodejs_version: "8"
install:
- ps: Install-Product node $env:nodejs_version
- npm install
Expand All @@ -10,4 +10,4 @@ test_script:
- npm run lint
- npm run test:security
- npm run test:code
build: off
build: off
30 changes: 15 additions & 15 deletions index.js
@@ -1,19 +1,19 @@
const debug = require('debug')('yeps:wrapper');

module.exports = fn => async context => {
debug('Wrapper created');
return new Promise((resolve, reject) => {
context.res.on('finish', () => {
debug('Response finished');
reject();
});
fn(context.req, context.res, error => {
debug(error);
if (error) {
reject(error);
} else {
resolve();
}
});
module.exports = fn => async (context) => {
debug('Wrapper created');
return new Promise((resolve, reject) => {
context.res.on('finish', () => {
debug('Response finished');
reject();
});
fn(context.req, context.res, (error) => {
debug(error);
if (error) {
reject(error);
} else {
resolve();
}
});
});
};
55 changes: 29 additions & 26 deletions package.json
@@ -1,17 +1,17 @@
{
"name": "yeps-express-wrapper",
"version": "1.0.0",
"version": "1.0.1",
"description": "YEPS express wrapper",
"main": "index.js",
"scripts": {
"lint": "./node_modules/.bin/npm-run-all --parallel lint:**",
"lint:js": "./node_modules/.bin/eslint index.js tests",
"test": "./node_modules/.bin/npm-run-all --parallel test:**",
"test:security": "./node_modules/.bin/nsp check",
"test:code": "node ./node_modules/mocha/bin/_mocha tests --recursive",
"test:coverage": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- tests --recursive",
"report": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls",
"clear": "./node_modules/.bin/rimraf coverage",
"lint": "npm-run-all lint:**",
"lint:js": "eslint index.js tests",
"test": "npm-run-all test:**",
"test:security": "nsp check",
"test:code": "mocha tests --recursive",
"test:coverage": "istanbul cover ./node_modules/mocha/bin/_mocha -- tests --recursive",
"report": "cat ./coverage/lcov.info | coveralls",
"clear": "rimraf coverage",
"precommit": "npm run lint && npm test",
"prepush": "npm run lint && npm test"
},
Expand Down Expand Up @@ -47,24 +47,27 @@
"node": ">=7.6.0"
},
"devDependencies": {
"body-parser": "^1.16.1",
"chai": "^3.5.0",
"body-parser": "^1.18.2",
"chai": "^4.1.2",
"chai-http": "^3.0.0",
"coveralls": "^2.11.16",
"debug": "^2.6.1",
"eslint": "^3.15.0",
"eslint-config-eslint": "^3.0.0",
"husky": "^0.13.1",
"coveralls": "^3.0.0",
"eslint": "^4.10.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.8.0",
"husky": "^0.14.3",
"istanbul": "^1.1.0-alpha.1",
"mocha": "^3.2.0",
"mocha-lcov-reporter": "^1.2.0",
"npm-run-all": "^4.0.1",
"nsp": "^2.6.2",
"promise-pause-timeout": "^1.0.0",
"rimraf": "^2.5.4",
"serve-favicon": "^2.4.0",
"yeps": "^1.0.0",
"yeps-error": "^1.0.0",
"yeps-router": "^1.0.0"
"mocha": "^4.0.1",
"mocha-lcov-reporter": "^1.3.0",
"npm-run-all": "^4.1.1",
"nsp": "^3.0.0",
"rimraf": "^2.6.2",
"serve-favicon": "^2.4.5",
"yeps": "^1.0.1",
"yeps-error": "^1.2.2",
"yeps-router": "^1.1.0",
"yeps-server": "^1.1.0"
},
"dependencies": {
"debug": "^3.1.0"
}
}

0 comments on commit c8a94b2

Please sign in to comment.