@thisisagile/easy
Advanced tools
Comparing version 1.12.4 to 1.12.5
@@ -1,7 +0,7 @@ | ||
import { List, Uri } from '../types'; | ||
import { Constructor, List, Uri } from '../types'; | ||
import { HttpVerb } from './HttpVerb'; | ||
import { Req } from './Req'; | ||
export declare type Endpoint = (re: Req) => Promise<unknown | List<unknown>>; | ||
export declare const route: (uri: Uri) => ClassDecorator; | ||
declare class Router { | ||
export declare type Endpoint<T> = (re: Req) => Promise<T | List<T>>; | ||
declare class Router<T> { | ||
readonly resource: unknown; | ||
@@ -12,6 +12,6 @@ constructor(resource: unknown); | ||
verb: HttpVerb; | ||
f: Endpoint; | ||
f: Endpoint<T>; | ||
}>; | ||
} | ||
export declare const router: (resource: unknown) => Router; | ||
export declare const router: <T>(resource: Constructor<T>) => Router<T>; | ||
export {}; |
@@ -17,4 +17,4 @@ "use strict"; | ||
} | ||
const router = (resource) => new Router(resource); | ||
const router = (resource) => new Router(new resource()); | ||
exports.router = router; | ||
//# sourceMappingURL=Route.js.map |
{ | ||
"name": "@thisisagile/easy", | ||
"version": "1.12.4", | ||
"version": "1.12.5", | ||
"description": "Straightforward library for building domain-driven microservice architectures", | ||
@@ -5,0 +5,0 @@ "author": "Sander Hoogendoorn", |
@@ -1,2 +0,2 @@ | ||
import { List, meta, Uri } from '../types'; | ||
import { Constructor, List, meta, Uri } from '../types'; | ||
import { HttpVerb } from './HttpVerb'; | ||
@@ -6,8 +6,8 @@ import { Verb } from './Verb'; | ||
export type Endpoint = (re: Req) => Promise<unknown | List<unknown>>; | ||
export const route = (uri: Uri): ClassDecorator => | ||
(subject: Function): void => { meta(subject).set('route', uri); }; | ||
class Router { | ||
export type Endpoint<T> = (re: Req) => Promise<T | List<T>>; | ||
class Router<T> { | ||
constructor(readonly resource: unknown) {} | ||
@@ -17,3 +17,3 @@ | ||
get endpoints(): List<{ verb: HttpVerb, f: Endpoint }> { | ||
get endpoints(): List<{ verb: HttpVerb, f: Endpoint<T> }> { | ||
return meta(this.resource).properties('verb') | ||
@@ -24,2 +24,2 @@ .map(p => ({ verb: p.get<Verb>('verb').verb, f: (this.resource as any)[p.property] })); | ||
export const router = (resource: unknown) => new Router(resource); | ||
export const router = <T>(resource: Constructor<T>) => new Router<T>(new resource()); |
Sorry, the diff of this file is not supported yet
136684