1.0.0 • Published 2 years ago

@hitachi567/subdomain v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Subdomain

hitachi567 <abidai790@gmail.com>

Express middleware for handle request from subdomain

Requirements

  • node.js
  • npm or yarn

Getting started

npm install @hitachi567/subdomain

# or

yarn add @hitachi567/subdomain

Usage

import subdomain from '@hitachi567/subdomain';
import express from 'express';

let app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

app.set('subdomain offset', 3); // mydomain.tld.com
app.set('subdomain offset', 2); // mydomain.com
app.set('subdomain offset', 1); // localhost

app.use(subdomain(
    (req, res) => res.send(req.hostname),
    ['api', 'users']
));

app.use(subdomain(
    (req, res) => res.send(req.hostname),
    ['api', 'posts']
));

app.use(subdomain(
    (req, res) => res.send(req.hostname)
));

app.listen(5000, () => {
    console.log('Server started on http://localhost:5000')
});

Links

1.0.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago