generated from ehmicky/template-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.d.ts
36 lines (34 loc) · 997 Bytes
/
main.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import type { HttpResponse, Options } from 'error-http-response'
import type { Info } from 'modern-errors'
export type { HttpResponse, Options }
/**
* `modern-errors-http` plugin
*/
declare const plugin: {
name: 'http'
getOptions: (input: Options) => Options
instanceMethods: {
/**
* Converts `error` to a plain object to use in an HTTP response.
* Its shape follows [RFC 7807](https://www.rfc-editor.org/rfc/rfc7807)
* ("problem details").
*
* @example
* ```js
* const object = BaseError.httpResponse(error)
* // {
* // type: 'https://example.com/probs/auth',
* // status: 401,
* // title: 'AuthError',
* // detail: 'Could not authenticate.',
* // instance: '/users/62',
* // stack: `AuthError: Could not authenticate.
* // at ...`,
* // extra: { userId: 62 },
* // }
* ```
*/
httpResponse: (info: Info['staticMethods']) => HttpResponse
}
}
export default plugin