1.0.7 • Published 2 years ago
@abernier/redirect v1.0.7
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=/welcomeback
Publish to NPM
Ready to publish a new version to NPM registry?
Manually
- bump the
package.json
version npm login
if 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 --tags
Using CI/CD workflow
Pre-requisite:
1. Generate a new NPM access token on npmjs.com (you need a NPM account and be logged-in)
2. Set it as NPM_TOKEN
secret (in Settings > Secrets
and as referenced into cicd.yml
file)
Then, to release a new version on npm:
1. bump the package.json
version
2. then, create a new realese and wait for the ci/cd publish it
Links
- Announcement on reddit r/expressjs