1.0.3 • Published 5 years ago

subdomains v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

subdomains

subdomains downloads npm codecov Build Status

npm.io

This plugin supprots only Hapi

subdomains plugin adds subdomains & subdomain properties to request object

Usage

// file: server.js
const subdomains = require("subdomains");

server.register({
  plugin: subdomains,
  options: {
    // provide domain name for better results
    domainName: "yourdomain.co.in",
    // provide subdomains to exclude
    // or an empty array
    exclude: ["www", "api"]
  }
});

Example

http://users.kiprosh.trackive.com

// file server.js

"use strict";
const subdomains = require("subdomains");
const Hapi = require("hapi");

// Create a server with a host and port
const server = Hapi.server({
  host: "localhost",
  port: 8000
});

// Add the route
server.route({
  method: "GET",
  path: "/",
  handler: (request, reply) => {
    console.log(request.subdomains); // ['users', 'kiprosh']
    console.log(request.subdomain); // 'users'
    return "Home";
  }
});

server.register({
  plugin: subdomains,
  options: {
    // provide domain name for better results
    domainName: "trackive.com",
    // provide subdomains to exclude
    // or an empty array
    exclude: ["www", "api"]
  }
});

// Start the server
async function start() {
  try {
    await server.start();
  } catch (err) {
    console.log(err);
    process.exit(1);
  }

  console.log("Server running at:", server.info.uri);
}

start();

CONTRIBUTING

Whether you are a novice or experienced software developer, all contributions and suggestions are welcome!

  1. Clone repo

    git clone https://github.com/vemarav/subdomains.git
  2. Add features or bug fixes

  3. Make a Pull Request

    OR

    Report a bug here

Feel free to contribute, hosted on ❤️ with Github.

LICENSE

Package published under MIT License

Author

SOCIAL

Twitter Follow

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago