1.3.4 • Published 2 years ago

x-route-builder v1.3.4

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

x-route-builder

A light-weight utility for creating file based routing in frameworks like express.

Features:

  • File-based routing.
  • Can ignore files.
  • Can alter the file's route that is created.
  • Dynamic routes (req.params) - File:[id].js - Will be altered to /:id.
  • Dynamic middleware - Place _middleware.js file in routes directory. The middleware will be applied to all routes inside the directory but will not be applied to routes above the directory.
  • Fully customizable.
  • Will log the output if in development env.

Table of Contents

  1. Install
  2. Usage

Install

npm i x-route-builder 

Usage

Standard:

const Xrouter = require('x-route-builder')

// create the route builder passing in (app)
const xRouter = new XrouteBuilder({
  app: app,
})

// build the routes
xRouter.build()

Options:

const Xrouter = require('x-route-builder')

// create the route builder passing in (app & options)
const xRouter = new XrouteBuilder({
  // app
  app: app,
  // directory path to start reading and building routes in
  dirpath: path.join(__dirname, 'routes'),
  // base path to start routes from
  basepath: '/basepath',
  // files to ignore
  ignore: [
    'ignoreFile1.js', 'ignoreFile2.js'
    ],
  // files to change / keep index of new route names the same as files
  change: {
    file: [
      'file1.js', 'file2.js'
    ],
    new: [
      'newFile1Path', 'newFile2Path'
    ],
  }
})

// build the routes
xRouter.build()
1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.12

2 years ago

1.2.11

2 years ago

1.2.10

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago