0.0.1 • Published 10 years ago

yode-rewrite v0.0.1

Weekly downloads
4
License
-
Repository
github
Last release
10 years ago

Yode-server url rewrite plugin

NPM

Setup

npm install yode-rewrite

Add to a global config file ./server.js in plugins list:

var server = require('yode-server')

server.start({
    port: 80,
    projects_dir: __dirname + '/www',    
    tmp_dir: __dirname + '/tmp',         
    plugins: [
        'yode-rewrite'    
    ]
})

Usage

Example 1:

to serve http://<host>/catalogue/tv/lcd as http://<host>/catalogue/?section=tv&type=lcd, add to a project config www/<project_dir>/config.js:

.....

REWRITE_RULES: {
 "^\\/catalogue\\/([a-zA-Z^\\/]{1,})\\/([a-zA-Z^\\/]{1,})": "/catalogue/?section=$1&type=$2"
}
.....

Example 2:

to serve http://<host>/path.to.module.method/ as http://<host>/path.to.module:method/, add to a project config www/<project_dir>/config.js:

.....

REWRITE_RULES: {
    "^(\\/[a-zA-Z\\.^\\/^\\/]{1,})\\.([a-zA-Z^\\/]{1,})\\/":"$1:$2"
}

.....

LICENSE: LGPL v2.1

0.0.1

10 years ago