|
1 | 1 | import { IncomingMessage } from 'http' |
2 | 2 | import { ParsedUrlQuery } from 'querystring' |
3 | | -import rg from 'regexparam' |
4 | | -import { parse } from 'url' |
| 3 | + |
5 | 4 | import { Ranges } from 'range-parser' |
6 | 5 | import proxyAddr from 'proxy-addr' |
7 | 6 | import { App } from './app' |
8 | 7 | import type { Middleware, Handler } from '@tinyhttp/router' |
9 | 8 | import type { Response } from './response' |
10 | | -import { compileTrust, rgExec } from './utils/request' |
11 | | - |
12 | | -export const getQueryParams = (url = '/'): ParsedUrlQuery => { |
13 | | - return parse(url, true).query |
14 | | -} |
| 9 | +import { compileTrust } from './utils/request' |
15 | 10 |
|
16 | | -export type URLParams = { |
17 | | - [key: string]: string |
18 | | -} |
| 11 | +import type { URLParams } from '@tinyhttp/req' |
19 | 12 |
|
20 | | -export const getURLParams = (reqUrl = '/', url = '/'): URLParams => { |
21 | | - return rgExec(reqUrl, rg(url)) |
22 | | -} |
| 13 | +export { getURLParams } from '@tinyhttp/req' |
23 | 14 |
|
24 | 15 | export const getRouteFromApp = (app: App, handler: Handler<Request, Response>) => { |
25 | 16 | return app.middleware.find((h) => h.handler.name === handler.name) |
@@ -84,6 +75,8 @@ export type Connection = IncomingMessage['socket'] & { |
84 | 75 |
|
85 | 76 | export type Protocol = 'http' | 'https' | string |
86 | 77 |
|
| 78 | +export type { URLParams } |
| 79 | + |
87 | 80 | export interface Request extends IncomingMessage { |
88 | 81 | query: ParsedUrlQuery |
89 | 82 | params: URLParams |
|
0 commit comments