url-resolver-fs
v8.0.6
Published
resolves urls and provides fs like access
Downloads
181
Readme
url-resolver-fs
resolves urls and provides fs like access
API
Table of Contents
Resolver
Extends URLScheme
Holds a map of url-schemes and dispatches requests
Parameters
config
Object (optional, default{}
)predefinedConstructors
Array<URLScheme> schemes to start with (optional, default[]
)env
Object environment variables as present in process.env (optional, default{}
)
Properties
registerScheme
Register a scheme for later lookup
Parameters
scheme
URLScheme
schemeForURL
Get URLScheme for a given url
Parameters
url
URL
Returns URLScheme for a given url or undefined if nothing found
resolve
Resolve for a given url. Passes url to the registered scheme for remapping
Parameters
url
URL to be resolved
Returns URL resolved url or original URL if no remapping found
createContext
Create a new context
Parameters
options
Object context
Returns Context newly created context
provideCredentials
Called when authorization is required. Forwards the request to the registered auth providers
Parameters
realm
string requested realm
Returns Object credentials as given by one of the registered auth providers
Context
Holds context information
Parameters
Properties
base
Type: URL
resolve
Parameters
url
URL
Returns URL
provideCredentials
Called when authorization is required for a given realm asks options.provideCredentials() and resolver.provideCredentials()
Parameters
realm
Object requested (decoded) realm
Returns Promise<Object> credentials for the given realm
HTTPScheme
Extends URLScheme
URLScheme for http requests
Parameters
Properties
options
Object
fetch
Parameters
Returns Promise fetch result
get
Execute a GET request
Parameters
Returns Promise body of the response
put
Execute a PUT request
Parameters
context
Context execution contexturl
URL destinationstream
Stream content to be put to the urloptions
Object
stat
Execute a HEAD request
Parameters
Returns Object response object
addAuthorizationHeader
inserts the authorization data into the reguest header
Parameters
Returns boolean true if auth info has been written into headers
name
Returns string 'http'
defaultPort
Returns number 80 the http default port
optionsFromEnvironment
Extract options suitable for the constructor form the given set of environment variables
Parameters
env
Object
Returns Object undefined if no suitable environment variables have been found
HTTPSScheme
Extends HTTPScheme
URLScheme for https requests
name
Returns string 'https'
defaultPort
Returns number 443 the https default port
isSecure
Returns boolean true
URLScheme
Parameters
options
Object raw config
Properties
options
Object raw config
name
Should be overwritten to reflect the scheme name
Returns string scheme name (defaults to the class name)
defaultPort
Returns number default from static defaultPort
isSecure
Returns boolean default from static isSecure
list
List collection (directory)
Parameters
Returns Promise resolves to iterable entries
get
Get content of a url
Parameters
Returns Promise resolves to the content
stat
Delivers meta information for a given url
Parameters
Returns Promise resolves to one entry
put
Put the content of a stream to a given url
Parameters
Returns Promise resolves if stream has ben put to the url
delete
Deletes object at a given url
Parameters
Returns Promise resolves to the history of the object at the given url
history
Deliver history information for a given url
Parameters
Returns Promise resolves to the history of the object at the given url
provideCredentials
Called when authorization is required for a given realm Tries provideCredentials() on the options object first and then calls provideCredentials() on the context.
Parameters
Returns Promise<Object> holding the credentials
methods
supported methods
Returns Array<string> 'get', 'stat', 'put', 'delete', 'list', 'history'
isSecure
Returns boolean false
defaultPort
Returns mumber undefined by default
defaultOptions
Default configuration options
Returns Object
optionsFromEnvironment
Extract options suitable for the constructor form the given set of environment variables
Parameters
env
Object
Returns Object undefined if no suitable environment variables have been found
options
Pepare configuration by mixing together defaultOptions with actual options
Parameters
options
Object raw config
Returns Object combined options
URLMapperScheme
Extends URLScheme
Remap url special:some/path -> https://myserver.com/repo/some/path name: special baseScheme: https prefix: https://myserver.com/repo/
Parameters
baseScheme
URLSchemename
string of the newly created schemeprefix
string urls will be prefixed by this valueoptions
Properties
baseScheme
URLSchemename
string of the newly created schemeprefix
string urls will be prefixed by this value
remap
Remapps url by separating scheme (and direct following '/') from suffix and appending the suffix (in front)
Parameters
url
URL to be remapped
Returns URL remapped url
parseAuthenticate
- See: rfc7235
Parse WWW-Authenticate header and provide parts as object. provides a two level structure 1st. the algorithm and then the algorithm attributes
Parameters
source
string http header 'WWW-Authenticate'result
Object where to put result into (optional, default{}
)
Returns Object same as result
ResponseError
Extends Error
general fetch response error
install
With npm do:
npm install url-resolver-fs
license
BSD-2-Clause