@abernier/redirect
v1.0.7
Published
Connect/Express ?redirect middleware
Readme
Connect/Express ?redirect middleware.
In short, it allows you to override any route/handler res.redirect('/foo') with a ?redirect=/bar querystring param.
Examples
Setup:
import express from 'express'
import redirect from '@abernier/redirect'
const app = express()
app.use(redirect())Basic
app.post('/login', (req, res) => {
// ...
res.redirect('/profile') // default redirection
})Override the default redirection -> be redirected to /welcomeback by adding a ?redirect querystring param:
$ curl -XPOST http://localhost:3000/login?redirect=/welcomebackPublish to NPM
Ready to publish a new version to NPM registry?
Manually
- bump the
package.jsonversion npm loginif not alreadynpm publish
If successful, you should want to tag the version:
$ git add package.json
$ git commit -m "bump version"
$ git tag v1.0.1
$ git push --tagsUsing CI/CD workflow
Pre-requisite:
- Generate a new NPM access token on npmjs.com (you need a NPM account and be logged-in)
- Set it as
NPM_TOKENsecret (inSettings > Secretsand as referenced intocicd.ymlfile)
Then, to release a new version on npm:
- bump the
package.jsonversion - then, create a new realese and wait for the ci/cd publish it
Links
- Announcement on reddit r/expressjs
