Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
trailpack-hapi
Advanced tools
Hapi.js Trailpack. This pack binds the routes compiled in trailpack-router to a Hapi Server.
Hapi Trailpack. This pack binds the routes compiled in trailpack-router to a Hapi Server.
Load in your trailpack config.
// config/main.js
module.exports = {
// ...
packs: [
require('trailpack-core'),
require('trailpack-router'),
require('trailpack-hapi')
]
}
Choose a template engine.
// config/views.js
module.exports = {
engine: 'handlebars'
}
Then simply write your views in a directory called 'templates'! This feature has been tested with Jade and Handlebars.
See config/web.js
for an example.
port
The port to listen on. 3000
by default. Can also be set via the PORT
environment variable.
Configure your Hapi.Server
by adding options
property to the web.js
config in typical
Hapi.server format. See: http://hapijs.com/api#new-serveroptions
// config/web.js
module.exports = {
options: {
routes: {
cors: true
}
}
}
Register your hapi plugins by adding them to the config/web.js
config in typical Hapi
plugin format. See: http://hapijs.com/tutorials/plugins#loading-a-plugin
// config/web.js
module.exports = {
plugins: [
{
register: require('vision'),
options: { }
},
{
register: require('inert'),
options: { }
},
{
register: require('hapi-auth-hawk'),
options: { }
}
// ...
],
onPluginsLoaded: function (err) {
// Note that `this` is Trails `app` instance
this.packs.hapi.server.auth.strategy('default', 'hawk', { getCredentialsFunc: getCredentials });
}
}
// config/web.js
module.exports = {
views: {
engines: {
html: require('some-view-engine')
},
path: 'views'
}
}
// config/main.js
module.exports = {
paths: {
...
www: path.resolve(__dirname, '..', 'static')
...
}
}
This allows static files such as js or images to be served in the /static directory. If you prefer, feel free to use a name other than 'static'!
// config/main.js
module.exports = {
paths: {
...
www: [
{
path: path.resolve(__dirname, '..', 'static'),
humanUrl: '/admin'
},
{
path: path.resolve(__dirname, '..', 'uploads', 'pictures', 'cats'),
humanUrl: '/cats'
}
]
...
}
}
Also you can make multiple static assets with human url.
For example your static files in /uploads/pictures/cats
with humanUrl
you url look like http://example.com/cats
humanUrl
- not require
We love contributions! Please check out our Contributor's Guide for more information on how our projects are organized and how to get started.
FAQs
Hapi.js Trailpack. This pack binds the routes compiled in trailpack-router to a Hapi Server.
The npm package trailpack-hapi receives a total of 1 weekly downloads. As such, trailpack-hapi popularity was classified as not popular.
We found that trailpack-hapi 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.