You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

decade

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decade - npm Package Compare versions

Comparing version

to
1.0.1

{
"name": "decade",
"version": "1.0.0",
"version": "1.0.1",
"description": "Dead simple HTTP/s Server",

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

@@ -33,10 +33,11 @@ # Decade ☄️

### Plugin
Decade provides a simple **Plugin** system, a plugin should be an _something_ with a `register` method which will receive the **Server** instance, from there you can listen for and emit events.
Decade provides a simple **Plugin** system, a plugin should be _something_ with a `register` method which will receive the **Server** instance and a **Logger** instance, from there you can listen for and emit events.
```ts
import { Server } from "decade";
import { Server, Logger } from "decade";
export class MyPlugin implements Server.Plugin {
...
async register(server: Server): Promise<void> {
async register(server: Server, logger: Logger): Promise<void> {
this.server = server;
this.logger = logger;
server.on("request", this.doSomething.bind(this));

@@ -46,2 +47,3 @@ }

async someOtherMethod() {
this.logger.info("something happened!");
this.server.emit("customevent", "foo");

@@ -52,3 +54,3 @@ }

To use a plugin, use the `Server.plugin` method.
To use a plugin, pass an it into the `Server.plugin` method.
```ts

@@ -119,2 +121,6 @@ import { Server } from "decade";

Routes resolve sequentially so if you have multiple routes which match the request URL they will all be called in the order that they were added to the Router.
_A common oversight is resolving routes too early, like the proxy route above which resolves immediately. Routes should only resolve once they are finished interacting with the request and response objects._
### Middleware

@@ -121,0 +127,0 @@ By default incoming `request` objects aren't parsed for `JSON` or `URL Encoded` payloads but you can use built in Middleware to do this.