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