Subdomain Middleware for TrinteJS & ExpressJS Javascript Frameworks.
npm install trinte-subdomain

config/middleware.js
js
var subdomain = require('trinte-subdomain');
module.exports = function (app, express) {
app.use(subdomain({
base: 'mydomain.dev',
only : '(test|admin)',
except : '(group|panel|my)',
onSuccess: function(req, res, next){
console.log('onSuccess');
next();
},
onExcept: function(req, res, next){
console.log('onExcept');
next();
},
alias: {
'.*': 'admin'
}
}));
...
}
`
#### usage for namespace in project config/routes.js
`js
module.exports = function routes(map, app) {
map.namespace('admin', {
subdomain: true
}, function(admin) {
admin.resources('users');
});
...
});
`
$3
`js
var express = require('express');
var app = express();
var subdomain = require('trinte-subdomain');
...
app.use(subdomain({
base: 'mydomain.dev',
only : '(test|admin)',
except : '(group|panel|my)',
onSuccess: function(req, res, next){
console.log('onSuccess');
next();
},
onExcept: function(req, res, next){
console.log('onExcept');
next();
},
alias: {
'.*': 'admin'
}
}));
app.get('/subdomain/admin', function(req, res){
res.send('Ok!');
});
app.listen(3000);
`
$3
npm test
Options
-----------------
Name
Type
Default
Description
base
string
Base damain name (required)
only
string
null
Rewrite url only for specified subdomains
except
string
null
Dont rewrite url for specified subdomains
onSuccess
function
null
Call this function if url rewrited
onExcept
function
Call this function if except param test true
alias
object
null
Subdomains mapping like:
``
{
alias: {
'(admin|backend)': 'admin'
}
}
``
$3
(The MIT License)
Copyright (c) 2013 Alexey Gordeyev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
$3
- Visit the author website.
- Follow @biggora on Twitter for updates.
- Follow agbiggora on Facebook for updates.
- Report issues on the github issues page.
$3
- CaminteJS - Cross-db ORM for NodeJS
- 2CO - is the module that will provide nodejs adapters for 2checkout API payment gateway.