Skip to content

Commit

Permalink
server
Browse files Browse the repository at this point in the history
  • Loading branch information
evheniy committed Apr 30, 2017
1 parent ebf55ce commit 259e0dd
Show file tree
Hide file tree
Showing 13 changed files with 473 additions and 539 deletions.
38 changes: 19 additions & 19 deletions .eslintrc
@@ -1,20 +1,20 @@
{
"extends": "eslint",
"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
},
"globals": {
"fetch": false
}
{
"extends": "eslint",
"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
},
"globals": {
"fetch": false
}
}
10 changes: 5 additions & 5 deletions .gitignore
@@ -1,6 +1,6 @@
coverage
.idea
npm-debug.log
node_modules
.DS_Store
coverage
.idea
npm-debug.log
node_modules
.DS_Store
logs/*
6 changes: 3 additions & 3 deletions .istanbul.yml
@@ -1,4 +1,4 @@
instrumentation:
default-excludes: true
excludes: []
instrumentation:
default-excludes: true
excludes: []
include-all-sources: true
20 changes: 11 additions & 9 deletions .travis.yml
@@ -1,10 +1,12 @@
language: node_js
node_js:
- "7.6"
- "7.7"
services:
- redis-server
script:
- npm run lint
- npm run test
language: node_js
node_js:
- "7.6"
- "7.7"
- "7.8"
- "7.9"
services:
- redis-server
script:
- npm run lint
- npm run test
- npm run report
40 changes: 20 additions & 20 deletions LICENSE
@@ -1,21 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 Evheniy Bystrov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
The MIT License (MIT)
Copyright (c) 2017 Evheniy Bystrov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
83 changes: 33 additions & 50 deletions README.md
@@ -1,50 +1,33 @@
# YEPS app boilerplate

[![Build Status](https://travis-ci.org/evheniy/yeps-boilerplate.svg?branch=master)](https://travis-ci.org/evheniy/yeps-boilerplate)
[![Coverage Status](https://coveralls.io/repos/github/evheniy/yeps-boilerplate/badge.svg?branch=master)](https://coveralls.io/github/evheniy/yeps-boilerplate?branch=master)
[![Linux Build](https://img.shields.io/travis/evheniy/yeps-boilerplate/master.svg?label=linux)](https://travis-ci.org/evheniy/)
[![Windows Build](https://img.shields.io/appveyor/ci/evheniy/yeps-boilerplate/master.svg?label=windows)](https://ci.appveyor.com/project/evheniy/yeps-boilerplate)

[![Dependency Status](https://david-dm.org/evheniy/yeps-boilerplate.svg)](https://david-dm.org/evheniy/yeps-boilerplate)
[![devDependency Status](https://david-dm.org/evheniy/yeps-boilerplate/dev-status.svg)](https://david-dm.org/evheniy/yeps-boilerplate#info=devDependencies)
[![NSP Status](https://img.shields.io/badge/NSP%20status-no%20vulnerabilities-green.svg)](https://travis-ci.org/evheniy/yeps-boilerplate)

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/evheniy/yeps-boilerplate/master/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/evheniy/yeps-boilerplate.svg)](https://github.com/evheniy/yeps-boilerplate/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/evheniy/yeps-boilerplate.svg)](https://github.com/evheniy/yeps-boilerplate/network)
[![GitHub issues](https://img.shields.io/github/issues/evheniy/yeps-boilerplate.svg)](https://github.com/evheniy/yeps-boilerplate/issues)
[![Twitter](https://img.shields.io/twitter/url/https/github.com/evheniy/yeps-boilerplate.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=%5Bobject%20Object%5D)

## Packages

* [yeps](https://github.com/evheniy/yeps) - YEPS
* [yeps-promisify](https://github.com/evheniy/yeps-promisify) - YEPS kernel
* [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-express-wrapper](https://github.com/evheniy/yeps-express-wrapper) - YEPS express wrapper
* [config](https://github.com/lorenwest/node-config) - node.js config
* [winston](https://github.com/winstonjs/winston) - logger
* [ioredis](https://github.com/luin/ioredis) - promise based redis client
* [body-parser](https://github.com/expressjs/body-parser) - Node.js body parsing middleware
* [serve-favicon](https://github.com/expressjs/serve-favicon) - favicon serving middleware
* [serve-static](https://github.com/expressjs/serve-static) - Serve static files
* [cors](https://www.npmjs.com/package/cors) - middleware for dynamically or statically enabling CORS
* [helmet](https://github.com/helmetjs/helmet) - Helmet helps you secure your apps by setting various HTTP headers
* [compression](https://github.com/expressjs/compression) - Node.js compression middleware


## How to install

git clone https://github.com/evheniy/yeps-boilerplate.git
cd yeps-boilerplate
npm i

## How to run

npm start

## How to test

npm t
# YEPS app boilerplate

[![Build Status](https://travis-ci.org/evheniy/yeps-boilerplate.svg?branch=master)](https://travis-ci.org/evheniy/yeps-boilerplate)
[![Coverage Status](https://coveralls.io/repos/github/evheniy/yeps-boilerplate/badge.svg?branch=master)](https://coveralls.io/github/evheniy/yeps-boilerplate?branch=master)
[![Linux Build](https://img.shields.io/travis/evheniy/yeps-boilerplate/master.svg?label=linux)](https://travis-ci.org/evheniy/)
[![Windows Build](https://img.shields.io/appveyor/ci/evheniy/yeps-boilerplate/master.svg?label=windows)](https://ci.appveyor.com/project/evheniy/yeps-boilerplate)

[![Dependency Status](https://david-dm.org/evheniy/yeps-boilerplate.svg)](https://david-dm.org/evheniy/yeps-boilerplate)
[![devDependency Status](https://david-dm.org/evheniy/yeps-boilerplate/dev-status.svg)](https://david-dm.org/evheniy/yeps-boilerplate#info=devDependencies)
[![NSP Status](https://img.shields.io/badge/NSP%20status-no%20vulnerabilities-green.svg)](https://travis-ci.org/evheniy/yeps-boilerplate)

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/evheniy/yeps-boilerplate/master/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/evheniy/yeps-boilerplate.svg)](https://github.com/evheniy/yeps-boilerplate/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/evheniy/yeps-boilerplate.svg)](https://github.com/evheniy/yeps-boilerplate/network)
[![GitHub issues](https://img.shields.io/github/issues/evheniy/yeps-boilerplate.svg)](https://github.com/evheniy/yeps-boilerplate/issues)
[![Twitter](https://img.shields.io/twitter/url/https/github.com/evheniy/yeps-boilerplate.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=%5Bobject%20Object%5D)


## How to install

git clone https://github.com/evheniy/yeps-boilerplate.git
cd yeps-boilerplate
npm i

## How to run

npm start

## How to test

npm t

#### [YEPS documentation](http://yeps.info/)
30 changes: 15 additions & 15 deletions appveyor.yml
@@ -1,16 +1,16 @@
environment:
matrix:
- nodejs_version: "7.7"
install:
- ps: Install-Product node $env:nodejs_version
- npm install
test_script:
- nuget install redis-64 -excludeversion
- redis-64\tools\redis-server.exe --service-install
- redis-64\tools\redis-server.exe --service-start
- node --version
- npm --version
- npm run lint
- npm run test:security
- npm run test:code
environment:
matrix:
- nodejs_version: "7.7"
install:
- ps: Install-Product node $env:nodejs_version
- npm install
test_script:
- nuget install redis-64 -excludeversion
- redis-64\tools\redis-server.exe --service-install
- redis-64\tools\redis-server.exe --service-start
- node --version
- npm --version
- npm run lint
- npm run test:security
- npm run test:code
build: off
79 changes: 6 additions & 73 deletions bin/www
@@ -1,73 +1,6 @@
#!/usr/bin/env node

/**
* Module dependencies.
*/
const http = require('http');
const app = require('..');
const redis = require('yeps-redis/redis');

/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}

const bind = typeof port === 'string' ? `Pipe ${port}` : `Port ${port}`;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(`${bind} requires elevated privileges`);
process.exit(1);
break;
case 'EADDRINUSE':
console.error(`${bind} is already in use`);
process.exit(1);
break;
default:
throw error;
}
}

/**
* Event listener for HTTP server "listening" event.
*/

function onListening() {
const addr = server.address();
const bind = typeof addr === 'string' ? `pipe ${addr}` : `port ${addr.port}`;
console.log(`Listening on ${bind}`);
}

/**
* Create HTTP server.
*/
const server = http.createServer(app.resolve());

/**
* Listen on provided port, on all network interfaces.
*/
server.on('listening', onListening);
server.on('error', onError);
server.listen(parseInt(process.env.PORT || '3000', 10));

/**
* Stop server
*/
const stop = () => {
server.close(() => {
redis.disconnect();
console.log('Server stop');
process.exit();
});
};

/**
* Stop process
*/
process.on('SIGINT', stop);
process.on('SIGTERM', stop);
#!/usr/bin/env node

const app = require('..');
const server = require('yeps-server');

server.createHttpServer(app);
30 changes: 15 additions & 15 deletions config/default.json
@@ -1,16 +1,16 @@
{
"redis": {
"host": "127.0.0.1",
"port": 6379
},
"logger": {
"filename": "./logs/app.error.log",
"json": true,
"timestamp": true,
"logstash": true,
"showLevel": true,
"maxsize": 10000000,
"maxFiles": 5
},
"ttl": 86400
{
"redis": {
"host": "127.0.0.1",
"port": 6379
},
"logger": {
"filename": "./logs/app.error.log",
"json": true,
"timestamp": true,
"logstash": true,
"showLevel": true,
"maxsize": 10000000,
"maxFiles": 5
},
"ttl": 86400
}

0 comments on commit 259e0dd

Please sign in to comment.