8.0.6 • Published 4 years ago

url-resolver-fs v8.0.6

Weekly downloads
129
License
BSD-2-Clause
Repository
github
Last release
4 years ago

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

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

Returns Promise fetch result

get

Execute a GET request

Parameters

Returns Promise body of the response

put

Execute a PUT request

Parameters

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

8.0.6

4 years ago

8.0.5

4 years ago

8.0.4

5 years ago

8.0.3

5 years ago

8.0.2

5 years ago

8.0.1

5 years ago

8.0.0

5 years ago

7.3.6

6 years ago

7.3.5

6 years ago

7.3.4

6 years ago

7.3.3

6 years ago

7.3.2

6 years ago

7.3.1

6 years ago

7.3.0

6 years ago

7.2.2

6 years ago

7.2.1

6 years ago

7.2.0

6 years ago

7.1.0

6 years ago

7.0.3

6 years ago

7.0.2

6 years ago

7.0.1

6 years ago

7.0.0

6 years ago

6.6.0

6 years ago

6.5.0

6 years ago

6.4.0

6 years ago

6.3.5

6 years ago

6.3.4

6 years ago

6.3.3

6 years ago

6.3.2

6 years ago

6.3.1

6 years ago

6.3.0

6 years ago

6.2.0

6 years ago

6.1.0

6 years ago

6.0.2

6 years ago

6.0.1

6 years ago

6.0.0

6 years ago

5.2.8

6 years ago

5.2.7

6 years ago

5.2.6

6 years ago

5.2.5

6 years ago

5.2.4

6 years ago

5.2.3

7 years ago

5.2.2

7 years ago

5.2.1

7 years ago

5.2.0

7 years ago

5.1.0

7 years ago

5.0.4

7 years ago

5.0.3

7 years ago

5.0.2

7 years ago

5.0.1

7 years ago

5.0.0

7 years ago

4.0.2

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.3

7 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago