Node Rest and Http Clients with typings for use with TypeScript
Перейти к файлу
Stephen Franceschelli 9ab5d63201
Yml bug fix. (#51)
2017-12-21 12:38:09 -05:00
docs updating readme sample 2017-11-20 10:46:13 -05:00
lib path fix and more tests 2017-12-07 07:53:32 -05:00
samples http tests and handler samples 2017-11-20 19:18:47 -05:00
test Enforce node and npm versions in make.js (#36) 2017-12-07 11:57:01 -05:00
.gitignore Users/stfrance/issue template (#37) 2017-12-07 08:21:34 -05:00
.vsts.ci.yml Yml bug fix. (#51) 2017-12-21 12:38:09 -05:00
CONTRIBUTING.md npm run bt 2017-12-07 08:14:01 -05:00
LICENSE contribution guide 2017-11-20 06:32:34 -05:00
README.md update readme 2017-12-07 08:27:54 -05:00
ThirdPartyNotices.txt initial commit 2017-01-08 17:21:28 -05:00
issue_template.md Users/stfrance/issue template (#37) 2017-12-07 08:21:34 -05:00
make.js Only enforce version on build. (#45) 2017-12-07 18:50:31 -05:00
package-lock.json Enforce node and npm versions in make.js (#36) 2017-12-07 11:57:01 -05:00
package.json Enforce node and npm versions in make.js (#36) 2017-12-07 11:57:01 -05:00
tsconfig.json refactor(casing): Force consistent casing (#25) 2017-11-30 17:55:52 -05:00

README.md

Typed Rest and Http Client with TypeScript Typings

A lightweight Rest and Http Client optimized for use with TypeScript with generics and async await.

Status

Stable version 0.15.6 and 1.0 is in preview (npm install typed-rest-client@preview). We expect to release 1.0 very soon.

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
  • Proxy support
  • Certificate support (Self-signed server and client cert)
  • Redirects supported

Intellisense and compile support from typing the REST calls: intellisense

Install the library

stable:

npm install typed-rest-client --save

latest preview:

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

Samples

See samples for complete coding examples

Also see 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. It's 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.

Contributing

To contribute to this repository, see the contribution guide

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.