Motivational plugin for Expressjs.
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
$ npm install express-motivation
The motivation
acts as a small middleware which will append an X-Motivation
header to each response.
You can also use the motivationErrorHandler
which will print out a standard Oh no!
error if there is an INTERNAL_SERVER_ERROR
.
const express = require('express')
const { motivation, motivationErrorHandler } = require('express-motivation')
const app = express()
app.use(motivation)
app.get('/', function (req, res) {
res.send('🍆 Hello there!')
})
app.get('/error', function (req, res, next) {
next(new Error("Big Error!"))
})
app.use(motivationErrorHandler)
app.listen(3000, () => {
console.log('🚀 Motivation app listening on port 3000')
})
The server will now respond as such:
HTTP/1.1 200 OK
X-Powered-By: Express
X-Motivation: Too many of us are not living our dreams because we are living our fears. - Les Brown
Content-Type: text/html; charset=utf-8
Content-Length: 17
Connection: close
🍆 Hello there!
We spend a whole lot of time writing, testing, and using RESTful APIs. This plugin helps to motivate you along the way.
If you are stuck trying to fix a bug on one of your endpoints, take a step back, and check what motivational phrase you are getting.
This is my first opensource project so I have no clue how to organize this. It would be cool to add different languages and configurations for this silly (yet fun) project.