2.2.0 • Published 5 years ago

sylph-router v2.2.0

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
5 years ago

Sylph Router

A small single-pass recursive directory scanner that extracts and returns exports you specify as an object with keys being based on folder structure. See Getting Started for more information.

Originally built to be consumed by Sylph, a rapid express-based API framework.

Since the creation of the Sylph Router it has shown to be extremely useful in many different scenarios, version 2.0 was built in order to facilitate more general use cases going forwards.

Getting Started

To install:

# With Yarn

yarn add sylph-router

# Or with NPM

npm i sylph-router

Next in order to scan a folder for modules and extract the handler export:

// TypeScript

import { scan, ScanResults } from 'sylph-router';

async function runScan() {
  const results: ScanResults = await scan('./directory', ['handler']);
  console.log(results);
}
// JavaScript

const { scan } = require('sylph-router');

async function runScan() {
  const results = await scan('./directory', ['handler']);
  console.log(results);
}
runScan()
// Deno

import { scan, ScanResults } from 
  'https://raw.githubusercontent.com/jetdevuk/sylph-router/master/deno.ts';

const results: ScanResults = await scan('./directory', ['handler']);
console.log(results);
2.2.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.1.0

6 years ago

1.0.0

6 years ago