GithubHelp home page GithubHelp logo

willsmythe / typed-rest-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/typed-rest-client

0.0 2.0 0.0 764 KB

Node Rest and Http Clients with typings for use with TypeScript

License: Other

JavaScript 18.39% TypeScript 81.61%

typed-rest-client's Introduction

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 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

Build

Build:

$ npm run build

Test

To run all tests:

$ npm test

To just run unit tests:

$ npm run units

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.

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

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 [email protected] with any additional questions or comments.

typed-rest-client's People

Contributors

bryanmacfarlane avatar stephenmichaelf avatar mmajcica avatar annich-ms avatar omeshp avatar devonsabbatical avatar tingluohuang avatar andrew8er avatar christlang avatar jungwoo-an avatar nicojs avatar olevett avatar williambernardet avatar tasadar2 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.