Nocturnal Pajama Mutants

    url-resolver-fs

    8.0.6 • Public • Published

    npm License minified size downloads GitHub Issues Build Status codecov.io Coverage Status styled with prettier Commitizen friendly Known Vulnerabilities Greenkeeper semantic-release

    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

    schemeForURL

    Get URLScheme for a given url

    Parameters

    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

    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

    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

    fetch

    Parameters

    • context Context execution context
    • url URL
    • options Object (optional, default {})

    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 context
    • url URL destination
    • stream Stream content to be put to the url
    • options Object

    stat

    Execute a HEAD request

    Parameters

    Returns Object response object

    addAuthorizationHeader

    inserts the authorization data into the reguest header

    Parameters

    • headers Object http credentials will be inserted into
    • credentials Object

    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

    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

    Properties

    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

    • context Context execution context
    • realm Object requested (decoded) realm

    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

    Returns Object undefined if no suitable environment variables have been found

    options

    Pepare configuration by mixing together defaultOptions with actual options

    Parameters

    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 URLScheme
    • name string of the newly created scheme
    • prefix string urls will be prefixed by this value
    • options

    Properties

    • baseScheme URLScheme
    • name string of the newly created scheme
    • prefix 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

    Install

    npm i url-resolver-fs

    DownloadsWeekly Downloads

    284

    Version

    8.0.6

    License

    BSD-2-Clause

    Unpacked Size

    40.5 kB

    Total Files

    12

    Last publish

    Collaborators

    • arlac77