@abernier/redirect 中文文档教程

发布于 3年前 浏览 17 项目主页 更新于 3年前

ci/cdNPM 版本覆盖状态

Connect/Express ?redirect 中间件。

简而言之,它允许您使用 ?redirect=/bar 查询字符串参数覆盖任何路由/处理程序 res.redirect('/foo')

Example

import express from 'express'
import redirect from '@abernier/redirect'

const app = express()
app.use(redirect())

// ...

app.post('/login', (req, res) => {
  // ...

  res.redirect('/profile') // *planned redirection
})

*用 redirect 查询字符串参数覆盖它:

$ curl -XPOST http://localhost:3000/login?redirect=/welcomeback

Publish to NPM

准备好将新版本发布到 NPM 注册表了吗?

Manually

  1. bump the package.json version
  2. npm login if not already
  3. npm publish

如果成功,您应该要标记版本:

$ git add package.json
$ git commit -m "bump version"
$ git tag v1.0.1
$ git push --tags

Using CI/CD workflow

先决条件:

  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)

然后,要在 npm 上发布新版本:

  1. bump the package.json version
  2. then, create a new realese and wait for the ci/cd publish it

ci/cdNPM versionCoverage Status

Connect/Express ?redirect middleware.

In short, it allows you to override any route/handler res.redirect('/foo') with a ?redirect=/bar querystring param.

Example

import express from 'express'
import redirect from '@abernier/redirect'

const app = express()
app.use(redirect())

// ...

app.post('/login', (req, res) => {
  // ...

  res.redirect('/profile') // *planned redirection
})

*Override it with redirect querystring param:

$ curl -XPOST http://localhost:3000/login?redirect=/welcomeback

Publish to NPM

Ready to publish a new version to NPM registry?

Manually

  1. bump the package.json version
  2. npm login if not already
  3. npm 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
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文