Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

trailpack

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trailpack - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

9

archetype/config/trailpack.js

@@ -7,2 +7,3 @@ /**

module.exports = {
type: 'misc',
/**

@@ -18,3 +19,3 @@ * Configure the lifecycle of this pack; that is, how it boots up, and which

*/
listen: [ ],
listen: [],

@@ -24,7 +25,7 @@ /**

*/
emit: [ ]
emit: []
},
initialize: {
listen: [ ],
emit: [ ]
listen: [],
emit: []
}

@@ -31,0 +32,0 @@ }

@@ -13,7 +13,9 @@ {

"devDependencies": {
"lodash": "^4.11.1",
"trails": "latest",
"eslint": "^2.4",
"eslint-config-trails": "^1.0.1",
"mocha": "^2.3",
"smokesignals": "^1.0.2",
"trailpack-core": "^1.0.0-beta-3"
"eslint-config-trails": "^1.0.4",
"mocha": "^2.4.5",
"smokesignals": "^1.0.9",
"trailpack-core": "^1.0.0-beta-6"
},

@@ -20,0 +22,0 @@ "scripts": {

@@ -113,2 +113,9 @@ 'use strict'

/**
* Expose the application's packs directly on the Trailpack for convenience.
*/
get packs () {
return this.app.packs
}
/**
* Return the name of this Trailpack. By default, this is the name of the

@@ -115,0 +122,0 @@ * npm module (in package.json). This method can be overridden for trailpacks

{
"name": "trailpack",
"version": "1.0.0",
"version": "1.0.1",
"description": "Trailpack Interface. Trailpacks extend the functionality of the Trails framework.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -42,4 +42,10 @@ # trailpack

initialize () {
setInterval(() => this.log.debug('happy?', this.app.config.example.happy), 1000)
this.interval = setInterval(() => {
this.log.debug('happy?', this.app.config.example.happy)
}, 1000)
}
unload () {
clearInterval(this.interval)
}
}

@@ -67,9 +73,54 @@ ```

0. `app.start`
1. Validate
2. Configure
3. Initialize
4. `app.ready`
0. [`trails:start`](https://github.com/trailsjs/trails/blob/master/index.js#L72) (event)
1. [`validate()`](https://github.com/trailsjs/trailpack/blob/master/index.js#L54-L61)
2. [`configure()`](https://github.com/trailsjs/trailpack/blob/master/index.js#L63-L70)
3. [`initialize()`](https://github.com/trailsjs/trailpack/blob/master/index.js#L72-L78)
4. [`trails:ready`](https://github.com/trailsjs/trails/blob/master/lib/trailpack.js#L38)
### Properties
#### `log`
Provides convenient access to the Trails logger. (e.g. `this.log.debug('hello')`)
#### `packs`
Access the application's loaded Trailpacks. This is a mapping of
name -> Trailpack. (e.g. `this.packs.core`)
#### `on`, `once`, `emit`, `after`
Emit/Listen for events on the Trails EventEmitter. Convenience methods for
`this.app.on`, `this.app.once`, etc. (e.g. `this.emit('custom:event')`)
### Methods
#### `constructor(app, definition)`
Instantiate the Trailpack. `definition` is an object which contains three
optional properties: `config`, `api`, `pkg`. Trailpack configuration is merged
into the application configuration.
#### `validate()`
Validate the preconditions for proper functioning of this trailpack. For
example, if this trailpack requires that a database is configured in
`config/database.js`, this method should validate this. This method should incur
no side-effects. *Do not alter any extant configuration.*
#### `configure()`
Alter/Extend the configuration (`app.config`) of the application, or
add new sections to the config object for the trailpack. This method
is run before the application is loaded -- after validate, and before
initialize. Trails does not allow further configuration changes after
this lifecycle stage is complete.
#### `initialize()`
If you need to bind any event listeners, start servers, connect to databases,
all of that should be done in initialize. The app's configuration is guaranteed to be
loaded and finalized before this stage.
#### `unload()`
Cleaup any resources/daemons started by this Trailpack. Used by [trailpack-autoreload](https://github.com/trailsjs/trailpack-autoreload)
and other system tools to cleanly release resources in order to
shutdown/restart the Trails application.
### Types
The trailpack `type` is used to distinguish between Trailpacks by the role they
perform in the application. It is also used by developer tools such as [Trailmix](https://github.com/trailsjs/trailsmix)

@@ -118,27 +169,5 @@ #### `abstract`

### Methods
#### `misc`
All trailpacks that don't fit previous types.
#### `constructor(app, definition)`
Instantiate the Trailpack. `definition` is an object which contains three
optional properties: `config`, `api`, `pkg`. Trailpack configuration is merged
into the application configuration.
#### `validate()`
Validate the preconditions for proper functioning of this trailpack. For
example, if this trailpack requires that a database is configured in
`config/database.js`, this method should validate this. This method should incur
no side-effects. *Do not alter any extant configuration.*
#### `configure()`
Alter/Extend the configuration (`app.config`) of the application, or
add new sections to the config object for the trailpack. This method
is run before the application is loaded -- after validate, and before
initialize. Trails does not allow further configuration changes after
this lifecycle stage is complete.
#### `initialize()`
If you need to bind any event listeners, start servers, connect to databases,
all of that should be done in initialize. The app's configuration is guaranteed to be
loaded and finalized before this stage.
## Contributing

@@ -145,0 +174,0 @@ We love contributions! Please see our [Contribution Guide](https://github.com/trailsjs/trails/blob/master/.github/CONTRIBUTING.md)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc