setup-go/node_modules/typed-rest-client
Thomas Boop 0caeaed6fd
Swap to Environment Files V1 Release (#77)
* Swap to Environment Files
2020-10-01 10:45:33 -04:00
..
handlers Add setup-go 2019-06-19 09:44:17 -04:00
opensource/node-http-ntlm Add setup-go 2019-06-19 09:44:17 -04:00
Handlers.d.ts Add setup-go 2019-06-19 09:44:17 -04:00
Handlers.js Add setup-go 2019-06-19 09:44:17 -04:00
HttpClient.d.ts Add setup-go 2019-06-19 09:44:17 -04:00
HttpClient.js Update toolkit 2019-06-24 15:05:39 -04:00
Index.d.ts Add setup-go 2019-06-19 09:44:17 -04:00
Index.js Add setup-go 2019-06-19 09:44:17 -04:00
Interfaces.d.ts Add setup-go 2019-06-19 09:44:17 -04:00
Interfaces.js Add setup-go 2019-06-19 09:44:17 -04:00
LICENSE Add setup-go 2019-06-19 09:44:17 -04:00
package.json Swap to Environment Files V1 Release (#77) 2020-10-01 10:45:33 -04:00
README.md Add setup-go 2019-06-19 09:44:17 -04:00
RestClient.d.ts Add setup-go 2019-06-19 09:44:17 -04:00
RestClient.js Add setup-go 2019-06-19 09:44:17 -04:00
ThirdPartyNotice.txt Add setup-go 2019-06-19 09:44:17 -04:00
Util.d.ts Add setup-go 2019-06-19 09:44:17 -04:00
Util.js Add setup-go 2019-06-19 09:44:17 -04:00

Build Status

Typed REST and HTTP Client with TypeScript Typings

A lightweight REST and HTTP client optimized for use with TypeScript with generics and async await.

Features

  • REST and HTTP client with TypeScript generics and async/await/Promises
  • Typings included so no need to acquire separately (great for intellisense and no versioning drift)
  • Basic, Bearer and NTLM Support out of the box. Extensible handlers for others.
  • Proxy support
  • Certificate support (Self-signed server and client cert)
  • Redirects supported

Intellisense and compile support:

intellisense

Install

npm install typed-rest-client --save

Or to install the latest preview:

npm install typed-rest-client@preview --save

Samples

See the samples for complete coding examples. Also see the REST and HTTP tests for detailed examples.

Errors

HTTP

The HTTP client does not throw unless truly exceptional.

  • A request that successfully executes resulting in a 404, 500 etc... will return a response object with a status code and a body.
  • Redirects (3xx) will be followed by default.

See HTTP tests for detailed examples.

REST

The REST client is a high-level client which uses the HTTP client. Its responsibility is to turn a body into a typed resource object.

  • A 200 will be success.
  • Redirects (3xx) will be followed.
  • A 404 will not throw but the result object will be null and the result statusCode will be set.
  • Other 4xx and 5xx errors will throw. The status code will be attached to the error object. If a RESTful error object is returned ({ message: xxx}), then the error message will be that. Otherwise, it will be a generic, Failed Request: (xxx).

See REST tests for detailed examples.

Debugging

To enable detailed console logging of all HTTP requests and responses, set the NODE_DEBUG environment varible:

export NODE_DEBUG=http

or

set NODE_DEBUG=http

Node support

The typed-rest-client is built using the latest LTS version of Node 8. We also support the latest LTS for Node 4 and Node 6.

Contributing

To contribute to this repository, see the contribution guide

To build:

$ npm run build

To run all tests:

$ npm test

To just run unit tests:

$ npm run units

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.