mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 08:17:05 +00:00
remove 2 arg version, Object to any
This commit is contained in:
Vendored
+10
-12
@@ -263,26 +263,24 @@ declare class Router {
|
||||
/**
|
||||
* Generate URL for route. Takes either map of named `params` or series of
|
||||
* arguments (for regular expression routes)
|
||||
*/
|
||||
url(name: string, params: Object): string;
|
||||
url(name: string, params: Object): Error;
|
||||
|
||||
/**
|
||||
* Generate URL for route with query part.
|
||||
*
|
||||
* Takes either map of named `params` or series of
|
||||
* arguments (for regular expression routes)
|
||||
* router = new Router();
|
||||
* router.get('user', "/users/:id", ...
|
||||
*
|
||||
* Query is generated from `options` argument:
|
||||
* router.url('user', { id: 3 });
|
||||
* // => "/users/3"
|
||||
*
|
||||
* Query can be generated from third argument:
|
||||
*
|
||||
* router.url('user', { id: 3 }, { query: { limit: 1 } });
|
||||
* // => "/users/3?limit=1"
|
||||
*
|
||||
*
|
||||
* router.url('user', { id: 3 }, { query: "limit=1" });
|
||||
* // => "/users/3?limit=1"
|
||||
*
|
||||
*/
|
||||
url(name: string, params: Object, options?: Router.IUrlOptionsQuery): string;
|
||||
url(name: string, params: Object, options?: Router.IUrlOptionsQuery): Error;
|
||||
url(name: string, params: any, options?: Router.IUrlOptionsQuery): string;
|
||||
url(name: string, params: any, options?: Router.IUrlOptionsQuery): Error;
|
||||
|
||||
/**
|
||||
* Match given `path` and return corresponding routes.
|
||||
|
||||
@@ -14,16 +14,20 @@ router
|
||||
.get('/', function (ctx, next) {
|
||||
ctx.body = 'Hello World!';
|
||||
})
|
||||
.get('/users/:id', function (ctx, next) {
|
||||
ctx.body = ctx.router.url('user-accounts', { id: ctx.params.id })
|
||||
.get('user', '/users/:id', function (ctx, next) {
|
||||
ctx.body = {
|
||||
test1: ctx.router.url('user-accounts', { id: ctx.params.id }),
|
||||
test2: ctx.router.url('user-accounts', ctx.params.id),
|
||||
test3: ctx.router.url('user-accounts', [ctx.params.id]),
|
||||
}
|
||||
})
|
||||
.get('user-accounts', '/users/:id/accounts', function (ctx, next) {
|
||||
ctx.body = {
|
||||
test1: ctx.router.url('users', { id: 3 }, { query: { limit: 1 } }),
|
||||
test2: ctx.router.url('users', { id: 3 }, { query: "limit=1" }),
|
||||
test3: ctx.router.url('users', 3, { query: { limit: 1 } }),
|
||||
test4: ctx.router.url('users', [3], { query: "limit=1" }),
|
||||
test5: ctx.router.url('users', ["3"], { query: { limit: "1" } }),
|
||||
test1: ctx.router.url('user', { id: 3 }, { query: { limit: 1 } }),
|
||||
test2: ctx.router.url('user', { id: 3 }, { query: "limit=1" }),
|
||||
test3: ctx.router.url('user', 3, { query: { limit: 1 } }),
|
||||
test4: ctx.router.url('user', [3], { query: "limit=1" }),
|
||||
test5: ctx.router.url('user', ["3"], { query: { limit: "1" } }),
|
||||
}
|
||||
})
|
||||
.post('/users', function (ctx, next) {
|
||||
|
||||
Reference in New Issue
Block a user