Module: @divine/uri
Namespaces
Classes
- AuthScheme
- AuthSchemeError
- Base64Encoder
- BasicAuthScheme
- BasicCredentials
- BearerAuthScheme
- BearerCredentials
- BufferParser
- CSVParser
- CacheURI
- DBError
- DBQuery
- DBResult
- DatabaseURI
- Encoder
- EncoderError
- EventStreamParser
- FileURI
- FormParser
- HTTPURI
- IOError
- IdentityEncoder
- JSONParser
- MessageParser
- MultiPartParser
- Parser
- ParserError
- PassThroughParser
- QuotedPrintableEncoder
- StringParser
- TOMLParser
- URI
- UnknownAuthScheme
- YAMLParser
- ZlibEncoder
Interfaces
- AuthSchemeRequest
- AuthSelector
- Credentials
- CredentialsProviderOptions
- DBColumnInfo
- DBMetadata
- DBParams
- DBParamsSelector
- DBTransactionParams
- DirectoryEntry
- EventStreamEvent
- FileWatchEvent
- Finalizable
- FormData
- FormField
- HTTPParams
- HTTPParamsSelector
- HawkCredentials
- HeadersSelector
- Metadata
- MimeMessage
- MimeMessageLike
- MultiPartData
- MultiPartField
- ParamsSelector
- PasswordCredentials
- Selector
- WithFields
Type Aliases
CredentialsProvider
Ƭ CredentialsProvider<C>: (options: CredentialsProviderOptions<C>) => Promise<C | undefined>
Type parameters
| Name | Type | Description | 
|---|---|---|
| C | extends Credentials | The type of credentials that is to be provied. | 
Type declaration
▸ (options): Promise<C | undefined>
A function used to provide or validate credentials for a request.
Params
options Information about the request how the provider should operate.
Parameters
| Name | Type | 
|---|---|
| options | CredentialsProviderOptions<C> | 
Returns
Promise<C | undefined>
Defined in
Variables
FIELDS
• Const FIELDS: typeof FIELDS
Used in WithFields to attach field metadata to an object.
Defined in
FINALIZE
• Const FINALIZE: typeof FINALIZE
Used in Finalizable to attach a finializer function to an object.
Defined in
HEADERS
• Const HEADERS: typeof HEADERS
Used in Metadata to attach response headers to an object.
Defined in
NULL
• Const NULL: typeof NULL
This symbol, wrapped in an Object, represents a null value.
Defined in
STATUS
• Const STATUS: typeof STATUS
Used in Metadata to attach a response status code to an object.
Defined in
STATUS_TEXT
• Const STATUS_TEXT: typeof STATUS_TEXT
Used in Metadata to attach a response status message to an object.
Defined in
VOID
• Const VOID: typeof VOID
This symbol, wrapped in an Object, represents an undefined value.
Defined in
Functions
encodeFilePath
▸ encodeFilePath(filepath, type?): string
Normalizes a file path and then applies percentEncode to each individual path components.
Parameters
| Name | Type | Description | 
|---|---|---|
| filepath | string | The file path to encode. | 
| type? | "posix"|"windows" | Indictes how the file path should be normalized. | 
Returns
string
The encoded file path.
Defined in
guessContentType
▸ guessContentType(pathname, knownContentType?): ContentType | undefined
If the media type is unknown, guesses the content type based on a path/file name. If the media type is known, that is what will be returned.
Parameters
| Name | Type | Description | 
|---|---|---|
| pathname | string | The name of the object whose media type to guess. | 
| knownContentType? | string|ContentType | If provided, the actual media type. | 
Returns
ContentType | undefined
The value of knownContentType or a media type derived from the file name extension, or
undefined.
Defined in
guessFileExtension
▸ guessFileExtension(contentType, invent, knownExtension?): string
If the file extension is unknown, derives the file name extension based on a media type. If the file extension is known, that is what will be returned.
Parameters
| Name | Type | Description | 
|---|---|---|
| contentType | string|ContentType | The media type of the object whose file extension to guess. | 
| invent | true | Set to trueto invent an unofficial file extension if none could be guessed based on the media type. | 
| knownExtension? | string | If provided, the actual file extension. | 
Returns
string
The value of knownExtension or a file extension derived from the media type.
Defined in
▸ guessFileExtension(contentType, invent?, knownExtension?): string | undefined
If the file extension is unknown, derives the file name extension based on a media type. If the file extension is known, that is what will be returned.
Parameters
| Name | Type | Description | 
|---|---|---|
| contentType | string|ContentType | The media type of the object whose file extension to guess. | 
| invent? | boolean | If false, this method returnsundefinedif the file extension is unknown. | 
| knownExtension? | string | If provided, the actual file extension. | 
Returns
string | undefined
The value of knownExtension or a file extension derived from the media type, or
undefined if the file extension is unknown.
Defined in
isEventStreamEvent
▸ isEventStreamEvent(event): event is EventStreamEvent
Checks whether the passed argument is an EventStreamEvent.
Parameters
| Name | Type | Description | 
|---|---|---|
| event | any | The object to check | 
Returns
event is EventStreamEvent
true if event is an EventStreamEvent.
Defined in
uri/src/parsers/event-stream.ts:25
q
▸ q(query, ...params): DBQuery
Constructs a DBQuery from a template literal.
All values/parameters will either be quoted and encoded or sent separately to the database server for processing, depending on the actual database driver. Example:
const query = q`select * from table where first_name = ${firstName}`;
See also quote, raw, join, list, values and assign for handy utility functions.
Throws
TypeError  If one of the parameters is undefined.
Parameters
| Name | Type | 
|---|---|
| query | TemplateStringsArray | 
| ...params | unknown[] | 
Returns
A new DBQeury object.
Defined in
uri/src/protocols/database.ts:30
▸ q(query, params): DBQuery
Constructs a DBQuery from a query string. The string may contain {prop} placeholders, which will then be
resolved against properties in params.
All values/parameters will either be quoted and encoded or sent separately to the database server for processing, depending on the actual database driver. Example:
const query = q('select * from table where first_name = {name}', { name: firstName });
See also quote, raw, join, list, values and assign for handy utility functions.
Throws
TypeError  If one of the parameters is undefined.
Parameters
| Name | Type | Description | 
|---|---|---|
| query | string | The query, with {prop}placeholders for parameters. | 
| params | Params | An record with parameters, used to look up placeholders from the query. Parameters may be DBQuery instances themselves, or of any type supported by the database. | 
Returns
A new DBQeury object.
Defined in
uri/src/protocols/database.ts:51
toObject
▸ toObject<T>(value): T
Converts a primitive value to an object and returns objects as-is.
undefined will be converted to Object(VOID) and null to Object(NULL). Any other non-object value
will be converted via Object(value), which means that a string value will become a String object, a number will
become a Number instance, et cetera.
toPrimitive can be used to reverse this operation.
Type parameters
| Name | Type | 
|---|---|
| T | extends object | 
Parameters
| Name | Type | Description | 
|---|---|---|
| value | unknown | The value to convert to an object. | 
Returns
T
The value converted to an object.
Defined in
toPrimitive
▸ toPrimitive(value): BasicTypes | symbol | undefined
Converts an object created by toObject back into the original value.
Parameters
| Name | Type | Description | 
|---|---|---|
| value | any | The object that should be converted back to its original value. | 
Returns
BasicTypes | symbol | undefined
The original value.
Defined in
uri
▸ uri(strings, ...values): string
@divine/uri template literal tag function that applies percentEncode to all arguments
Parameters
| Name | Type | Description | 
|---|---|---|
| strings | TemplateStringsArray | The template string array. | 
| ...values | unknown[] | The values to be encoded. | 
Returns
string
A string with the arguments encoded.