
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
bookshelf-consul-pilot
Advanced tools
Create a Knex/Bookshelf connection that updates dynamically using consul-pilot.
Your database connection file might look something like this:
const BookshelfConsulPilot = require('bookshelf-consul-pilot');
const knexfile = require('../../knexfile').development;
const path = require('path');
// Argument 1: The knex config that you would use to instantiate Bookshelf
// Argument 2: The Consul database service name to listen for changes in connections on
// Argument 3: The path to your Bookshelf models folder that bookshelf-consul-pilot will read models from
// Argument 4: A function for configuring Bookshelf plugins. This will called every time a new connection is reported
// Argument 5: Optionally bypass the new connection watching by passing true. Useful for dev and in some cases unit testing
module.exports = new BookshelfConsulPilot(knexfile, 'database', path.join(__dirname, '/../models'), (bookshelf) => {
bookshelf.plugin('pagination');
bookshelf.plugin(require('bookshelf-signals')());
});
Ensure that your model files are wrapped in a function that accepts bookshelf as an argument:
module.exports = (bookshelf) => {
return bookshelf.Model.extend({
tableName: 'books',
});
};
// include the file created in the Installation step
const db = require('database');
// you can fetch the bookshelf and knex instances like so
// db.bookshelf
// db.knex
function getBooks() {
// when using Bookshelf models, always fetch the model instance like so. The 'book' argument is
// the filename of your model in the models directory you specified in the Installation step
db.model('book').fetchPage()
.then((books) => {
console.log(books);
});
}
Anything that must modify the Bookshelf instance or its models must be wrapped in a register. This allows bookshelf-consul-pilot to completely reset the Bookshelf instance if a new connection were to be reported. An example is events using the bookshelf-signals plugin:
const db = require('database');
db.register((bookshelf) => {
bookshelf.on('created', db.model('book'), (model) => {
console.log('created fired!');
});
bookshelf.on('updated', db.model('book'), (model) => {
console.log('updated fired!');
});
});
FAQs
Create a Knex/Bookshelf connection that updates dynamically using consul-pilot.
The npm package bookshelf-consul-pilot receives a total of 3 weekly downloads. As such, bookshelf-consul-pilot popularity was classified as not popular.
We found that bookshelf-consul-pilot demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.