routes-getter

0.0.4 • Public • Published

routes-getter

Accessible routes in your ExpressJS application

Centered image

An easy way of working with your routes in ExpressJS applications. It walks through your routes folder and imports them to your project.

Note - It does not walk through the middlewares folder in your routes folder. Since they are used and shared by routes as further middlewares.

Table of Contents

  • Installation
  • Examples
  • API

Installation

npm install -g routes-getter

Examples

Assuming the src directory to be the application folder, this is how you will define the routes

// src/routes/index.js

module.exports = (app) => {
	app.get('/', (req, res) => x{
		res.render('../views/index.html');
	});
}

server.js file in your app directory.

const express = require('express');
const loader = require('routes-getter');

const app = express();

loader.routers(__dirname + '/routes', app); // Loads the routes in your application

API

loader.routers([options])

options

path

Required

Path to routes in your application folder.

app

Required

app should be instance of express

Tests

npm test

Contributing

Add unit tests for any new or changed functionality.

License

ISC

Readme

Keywords

none

Package Sidebar

Install

npm i routes-getter

Weekly Downloads

1

Version

0.0.4

License

ISC

Last publish

Collaborators

  • nitin42