README
rewrite-handler
:boom: [ESM] The rewrite handler for Node.js
Example
Full example in /example
folder.
import { REDIRECT_STATUS_CODES, rewriteHandler } from '@awesomeorganization/rewrite-handler'
import { http } from '@awesomeorganization/servers'
import { staticHandler } from '@awesomeorganization/static-handler'
const example = async () => {
const rewriteMiddleware = rewriteHandler({
rules: [
{
pattern: '^/old-files/(.*)',
replacement: '/files/$1',
statusCode: REDIRECT_STATUS_CODES.MOVED_PERMANENTLY,
},
{
pattern: '(.*)/