Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lark-router

Package Overview
Dependencies
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lark-router - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

1

index.js

@@ -173,2 +173,3 @@ /**

this.emit('error', e, req, ...args);
throw e;
});

@@ -175,0 +176,0 @@ }

2

package.json
{
"name": "lark-router",
"version": "1.1.1",
"version": "1.1.2",
"description": "An koa route initialization and configuration module.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -97,2 +97,3 @@ lark-router

```
## Async processors

@@ -107,6 +108,46 @@

## Loading files and directories to generate route rules
TBD...
## DETAILED DOC
TBD...
Use `router.load(path)` to load a file or a directory.
If the `path` is a file, it should export a function or an object.
* function
The function accepts the router as parameter.
```javascript
module.exports = router => {
router.get('/foo/bar', (...args) => {...});
}
```
Or you can return a new one if you like, but this is not recommended since you may need to re-configure this sub-router, eg. setting a adapter for this router.
```javascript
module.exports = () => {
const router = new LarkRouter();
router.get('/foo/bar', (...args) => {...});
return router;
}
```
* Object
If an object is exported, all the properties of the object with name in the `router.methods` should be a function and will be processed as `router.route(key, value)`.
```javascript
module.exports = {
GET (ctx, next) => {...}
POST (ctx, next) => {...}
}
```
_Some methods (eg. delete) are reserved words, so we recommend words capitalized or in upper case, like `GET`, `Post`_
### Loading directories with file name as param
You may still want to use routes like `/:foo/:bar` in loading directories model. We have provide an adapter to do this. `router.adapter.parseFileName` will parse all file/directory names(without extend name) in the loading process. We provid a default one:
```
/foo.as.param/bar.as.param.js => /:foo/:bar
/foo/bar.as.asterisk.js => /foo/:bar*
```

@@ -113,0 +154,0 @@ [npm-image]: https://img.shields.io/npm/v/lark-router.svg?style=flat-square

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc