Comparing version 1.0.0-beta-7 to 1.0.0-beta-8
@@ -10,9 +10,6 @@ /** | ||
exports.database = require('./database') | ||
exports.footprints = require('./footprints') | ||
exports.i18n = require('./i18n') | ||
exports.policies = require('./policies') | ||
exports.routes = require('./routes') | ||
exports.web = require('./web') | ||
exports.session = require('./session') | ||
exports.views = require('./views') | ||
exports.webpack = require('./webpack') |
@@ -19,3 +19,3 @@ /** | ||
require('trailpack-router'), | ||
require('<%= trailpacks %>') | ||
require('<%- trailpacks %>') | ||
], | ||
@@ -22,0 +22,0 @@ |
@@ -9,3 +9,2 @@ { | ||
"dependencies": { | ||
"lodash": "^4.0", | ||
"trailpack-core": "^1.0.0-beta-3", | ||
@@ -20,14 +19,16 @@ "trailpack-repl": "^1.0.0-beta-3", | ||
"waterline-sqlite3": "^1.0.0", | ||
"winston": "^2.1.1" | ||
"winston": "^2.2" | ||
}, | ||
"devDependencies": { | ||
"eslint-config-trails": "latest", | ||
"eslint": "^1.10", | ||
"mocha": "^2.3", | ||
"supertest": "^1.1" | ||
"eslint": "^2.8", | ||
"mocha": "^2.4", | ||
"supertest": "^1.2" | ||
}, | ||
"bundledDependencies": [ | ||
"lodash", | ||
"trailpack-core", | ||
"trails" | ||
"trails", | ||
"trails-controller", | ||
"trails-policy", | ||
"trails-service" | ||
], | ||
@@ -34,0 +35,0 @@ "scripts": { |
27
index.js
/*eslint no-console: 0 */ | ||
'use strict' | ||
const path = require('path') | ||
const fs = require('fs') | ||
const events = require('events') | ||
@@ -38,18 +36,7 @@ const lib = require('./lib') | ||
console.error('A logger must be set at config.log.logger. Application cannot start.') | ||
console.error('e.g. new winston.Logger({ transports: [ new winston.transports.Console() ] )') | ||
console.error('e.g. new winston.Logger({ transports: [ new winston.transports.Console() ] })') | ||
console.error('For more info, see the config.log archetype: https://git.io/vVvUI') | ||
throw new Error('Trails logger is not defined') | ||
throw new lib.Errors.LoggerNotDefinedError() | ||
} | ||
try { | ||
fs.statSync(this.config.main.paths.root) | ||
} | ||
catch (e) { | ||
this.config.main.paths.root = path.resolve(process.cwd()) | ||
this.log.warn('The config setting main.paths.root is not found on disk') | ||
this.log.warn('Setting main.paths.root =', this.config.main.paths.root) | ||
this.log.warn('If this isn\'t your application\'s root, please set main.paths.root manually') | ||
} | ||
this.setMaxListeners(this.config.main.maxListeners) | ||
@@ -67,2 +54,6 @@ } | ||
start (app) { | ||
if (!this.api && !(app && app.api)) { | ||
throw new lib.Errors.ApiNotDefinedError() | ||
} | ||
if (this.api && app && app.api) { | ||
@@ -128,7 +119,2 @@ this.log.info('Starting trails app with new API definition') | ||
this.log.debug('trails event:', event) | ||
// allow errors to escape and be printed on exit | ||
// XXX this might only be needed because I don't have all the escape hatches | ||
// covered that errors can escape out of | ||
//process.nextTick(() => super.emit.apply(this, arguments)) | ||
super.emit.apply(this, arguments) | ||
@@ -159,2 +145,1 @@ } | ||
} | ||
exports.i18n = require('./i18n') | ||
exports.Trailpack = require('./trailpack') | ||
exports.Trails = require('./trails') | ||
exports.Errors = require('./errors') |
@@ -55,4 +55,2 @@ 'use strict' | ||
TrailsUtil.bindApplicationEvents(app) | ||
TrailsUtil.bindSystemEvents(app) | ||
app.bound = true | ||
@@ -69,16 +67,2 @@ }, | ||
/** | ||
* Bind listeners to node system events | ||
*/ | ||
bindSystemEvents (app) { | ||
process | ||
.on('exit', () => { | ||
app.log.verbose('Event loop is empty. Shutting down') | ||
}) | ||
.on('uncaughtException', err => { | ||
app.log.error('uncaughtException', err) | ||
app.stop(err) | ||
}) | ||
}, | ||
/** | ||
* Unbind all listeners that were bound during application startup | ||
@@ -88,8 +72,4 @@ */ | ||
app.removeAllListeners() | ||
process.removeAllListeners('exit') | ||
process.removeAllListeners('uncaughtException') | ||
app.bound = false | ||
} | ||
} |
{ | ||
"name": "trails", | ||
"version": "1.0.0-beta-7", | ||
"version": "1.0.0-beta-8", | ||
"description": "Modern Web Application Framework for Node.js", | ||
@@ -23,3 +23,4 @@ "keywords": [ | ||
"scripts": { | ||
"test": "eslint . && mocha" | ||
"test": "eslint . && mocha", | ||
"coverage": "istanbul cover _mocha" | ||
}, | ||
@@ -64,2 +65,3 @@ "repository": { | ||
"eslint-config-trails": "^1.0", | ||
"istanbul": "^0.4.2", | ||
"mocha": "^2.3.4", | ||
@@ -66,0 +68,0 @@ "trailpack": "^1.0.0-alpha-1", |
@@ -86,2 +86,3 @@ [![Trails.js][trails-image]][trails-url] | ||
#### Videos | ||
- [Getting Started with Trails.js](https://www.youtube.com/watch?v=AbSp8jqFDAY) | ||
@@ -144,2 +145,1 @@ #### Support | ||
[twitter-url]: https://twitter.com/trailsjs | ||
@@ -53,8 +53,4 @@ # trailmap | ||
The April 2016 release of Trails will constitute the first production-ready release. The following trailpacks also must reach v1.0 status: | ||
The April 2016 release of Trails will constitute the first production-ready release. | ||
- [trailpack-auth](https://github.com/trailsjs/trailpack-auth) ([v1.0 milestone](https://github.com/trailsjs/trailpack-auth/milestones/v1.0)) | ||
- [trailpack-permissions](https://github.com/trailsjs/trailpack-permissions) ([v1.0 milestone](https://github.com/trailsjs/trailpack-permissions/milestones/v1.0)) | ||
- [trailpack-sails](https://github.com/trailsjs/trailpack-sails) ([v1.0 milestone](https://github.com/trailsjs/trailpack-sails/milestones/v1.0)) | ||
##### Open Issues | ||
@@ -65,3 +61,3 @@ See: [trailsjs/trails/milestones/v1.0](https://github.com/trailsjs/trails/milestones/v1.0) | ||
### v1.x LTS (October 2016) | ||
### v2.0 LTS (October 2016) | ||
@@ -68,0 +64,0 @@ ## Past Releases |
@@ -6,2 +6,3 @@ 'use strict' | ||
const testAppDefinition = require('./testapp') | ||
const lib = require('../lib') | ||
@@ -12,7 +13,6 @@ describe('Trails', () => { | ||
it('should be able to start and stop many instances in a single node process', () => { | ||
let cycles = [ ] | ||
const cycles = [ ] | ||
for (let i = 0; i < 10; ++i) { | ||
cycles.push(new Promise (resolve => { | ||
//console.log('loading application; iteration', i) | ||
let app = new TrailsApp(testAppDefinition) | ||
const app = new TrailsApp(testAppDefinition) | ||
app.start(testAppDefinition) | ||
@@ -39,3 +39,3 @@ .then(app => { | ||
it('should be able to stop, then start the same app', () => { | ||
let app = new TrailsApp(testAppDefinition) | ||
const app = new TrailsApp(testAppDefinition) | ||
return app.start(testAppDefinition) | ||
@@ -62,16 +62,46 @@ .then(app => { | ||
it('should be instance of EventEmitter', () => { | ||
assert(app instanceof require('events').EventEmitter) | ||
describe('typical usage', () => { | ||
it('should be instance of EventEmitter', () => { | ||
assert(app instanceof require('events').EventEmitter) | ||
}) | ||
it('should set max number of event listeners', () => { | ||
assert.equal(app.getMaxListeners(), 128) | ||
}) | ||
it('should set app properties', () => { | ||
assert(app.pkg) | ||
assert(app.config) | ||
assert(app.api) | ||
}) | ||
it('should set NODE_ENV', () => { | ||
assert.equal(process.env.NODE_ENV, 'development') | ||
}) | ||
}) | ||
it('should set max number of event listeners', () => { | ||
assert.equal(app.getMaxListeners(), 128) | ||
describe('errors', () => { | ||
it('should throw LoggerNotDefinedError if logger is missing', () => { | ||
const def = { | ||
config: { | ||
main: { | ||
paths: { root: __dirname } | ||
} | ||
} | ||
} | ||
assert.throws(() => new TrailsApp(def), lib.Errors.LoggerNotDefinedError) | ||
}) | ||
it('should throw ApiNotDefinedError if no api definition is provided', () => { | ||
const def = { | ||
config: { | ||
main: { | ||
paths: { root: __dirname } | ||
}, | ||
log: { | ||
logger: { } | ||
} | ||
} | ||
} | ||
const app = new TrailsApp(def) | ||
assert.throws(() => app.start(), lib.Errors.ApiNotDefinedError) | ||
}) | ||
}) | ||
it('should set app properties', () => { | ||
assert(app.pkg) | ||
assert(app.config) | ||
assert(app.api) | ||
}) | ||
it('should set NODE_ENV', () => { | ||
assert.equal(process.env.NODE_ENV, 'development') | ||
}) | ||
}) | ||
@@ -78,0 +108,0 @@ |
@@ -16,3 +16,2 @@ module.exports = { | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
50
5
43179
6
745