Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ A lightweight library that brings some structure to Express.js

Check the `/example` folder for a basic todo app with database integration.

Sapling is also powering one of my more complex projects with 400+ users in production, which you can view at [instalock-web](https://github.com/tahminator/instalock-web).
Sapling is also powering one of my more complex projects with 600+ users in production, which you can view at [instalock-web](https://github.com/tahminator/instalock-web).

## Install

Expand Down Expand Up @@ -188,7 +188,7 @@ import { Controller, Middleware } from "@tahminator/sapling";
import cookieParser from "cookie-parser";
import { NextFunction, Request, Response } from "express";

@Controller()
@MiddlewareClass() // works the same as @Controller, semantically different
class CookieParserMiddleware {
private readonly plugin: ReturnType<typeof cookieParser>;

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
"import": "./dist/index.js",
"require": "./dist/index.js"
}
},
"files": [
Expand Down
1 change: 1 addition & 0 deletions src/annotation/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./controller";
export * from "./injectable";
export * from "./route";
export * from "./middleware";
14 changes: 14 additions & 0 deletions src/annotation/middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Controller } from "./controller";

/**
* Used to define a middleware-only class.
*
* __NOTE:__ `@MiddlewareClass` works exactly the same as `@Controller`. As such, you
* can still register `@Route` and `@Middleware` methods, though you very well should not
* for the sake of semantics.
*/
export function MiddlewareClass(
...args: Parameters<typeof Controller>
): ClassDecorator {
return Controller(...args);
}
Loading