mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
lint
This commit is contained in:
Vendored
+5
-4
@@ -35,11 +35,11 @@ export interface ActionContext<C extends Context, R = any> extends PathnameConte
|
||||
/**
|
||||
* Matched route object.
|
||||
*/
|
||||
route: Route<any, any>;
|
||||
route: Route;
|
||||
/**
|
||||
* Middleware style function which can continue resolving.
|
||||
*/
|
||||
next: (resume?: boolean, parent?: Route<any, any>, prevResult?: any) => Promise<R>;
|
||||
next: (resume?: boolean, parent?: Route, prevResult?: any) => Promise<R>;
|
||||
/**
|
||||
* Base URL path relative to the path of the current route.
|
||||
*/
|
||||
@@ -75,7 +75,7 @@ export interface Route<C extends Context = any, R = any> {
|
||||
/**
|
||||
* automatically filled by the router
|
||||
*/
|
||||
parent?: Route<any, any> | null;
|
||||
parent?: Route | null;
|
||||
/**
|
||||
* array of route objects
|
||||
*/
|
||||
@@ -107,7 +107,8 @@ export interface Options<C extends Context = Context, R = any> {
|
||||
export default class UniversalRouter<C extends Context = Context, R = any> {
|
||||
constructor(routes: Routes<C, R> | Route<C, R>, options?: Options<C>)
|
||||
/**
|
||||
* Traverses the list of routes in the order they are defined until it finds the first route that matches provided URL path string and whose action function returns anything other than null or undefined.
|
||||
* Traverses the list of routes in the order they are defined until it finds the first route that matches provided URL path string
|
||||
* and whose action function returns anything other than null or undefined.
|
||||
*/
|
||||
resolve(pathnameOrContext: string | PathnameContext): Promise<R>;
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ new UniversalRouter(
|
||||
},
|
||||
baseUrl: '/base',
|
||||
errorHandler: (error) => {
|
||||
console.error(error)
|
||||
console.dir(error.context)
|
||||
console.error(error);
|
||||
console.dir(error.context);
|
||||
return error.code === 404
|
||||
? '<h1>Page Not Found</h1>'
|
||||
: '<h1>Oops! Something went wrong</h1>'
|
||||
: '<h1>Oops! Something went wrong</h1>';
|
||||
},
|
||||
},
|
||||
).resolve('/').then(console.log);
|
||||
@@ -48,18 +48,18 @@ new UniversalRouter({
|
||||
new UniversalRouter({
|
||||
path: '', // optional
|
||||
async action({ next }) {
|
||||
console.log('middleware: start')
|
||||
const child = await next()
|
||||
console.log('middleware: end')
|
||||
return child
|
||||
console.log('middleware: start');
|
||||
const child = await next();
|
||||
console.log('middleware: end');
|
||||
return child;
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '/hello',
|
||||
action() {
|
||||
console.log('route: return a result')
|
||||
return 'Hello, world!'
|
||||
console.log('route: return a result');
|
||||
return 'Hello, world!';
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user