Comparing version 1.0.5 to 1.1.0
{ | ||
"name": "restyped", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "End-to-end typing for REST APIs with TypeScript", | ||
@@ -14,3 +14,3 @@ "main": "index.ts", | ||
}, | ||
"author": "", | ||
"author": "Arman Dezfuli-Arjomandi", | ||
"license": "MIT", | ||
@@ -17,0 +17,0 @@ "bugs": { |
@@ -9,4 +9,2 @@ <p align="center"> | ||
## Motivation | ||
Read the [blog post](https://blog.falcross.com/) | ||
Typescript is a one-way street: Once you start using it, it's hard to go back to plain JS. In fact, you'll probably want to write your entire application in TypeScript. | ||
@@ -24,3 +22,3 @@ | ||
- **Lightweight.** Most server and client implementations don't even add any code--just types | ||
- **Use existing syntax.** Declare and call your HTTP routes the same way you always have | ||
- **Use existing syntax.** Write your REST routes and clients the same way you always have | ||
- **Great for private APIs.** Keep API clients across your organization in sync with the latest changes | ||
@@ -31,6 +29,6 @@ - **Great for public APIs.** Create an API definition so TypeScript users can consume your API fully typed | ||
## How to use it | ||
RESTyped is a specification. Once you spend a few minutes typing your API using the specification below, you can use these server and client wrappers to declare and consume your API in a type-safe manner: | ||
RESTyped is a specification. Once you spend a few minutes typing your API using the spec below, you can use these server and client typings to declare and consume your API in a type-safe manner: | ||
- [restyped-axios](https://github.com/rawrmaan/restyped-axios) - Client wrapper for Axios to consume RESTyped APIs | ||
- [restyped-express](https://github.com/rawrmaan/restyped-express) - Server wrapper for express to deliver RESTyped APIs | ||
- [restyped-axios](https://github.com/rawrmaan/restyped-axios) - Client typings for Axios to consume RESTyped APIs | ||
- [restyped-express-async](https://github.com/rawrmaan/restyped-express-async) - Server library for express to deliver RESTyped APIs using promises (WIP) | ||
@@ -114,7 +112,7 @@ You can help make RESTyped more useful by typing your favorite server framework or HTTP client! | ||
### 2. Serve the API via express | ||
### 2. Declare the API via express | ||
```typescript | ||
import {AsyncRouter} from 'restyped-express' | ||
import {FoodDeliveryAPI} from './api.d.ts' | ||
import {FoodDeliveryAPI} from './food-delivery-api' | ||
@@ -139,3 +137,3 @@ import OrderModel from './controllers/order' | ||
import axios from 'restyped-axios' | ||
import {FoodDeliveryAPI} from './api.d.ts' | ||
import {FoodDeliveryAPI} from './food-delivery-api' | ||
@@ -162,1 +160,5 @@ const api = axios.create({baseURL: 'https://fooddelivery.com/api/'}) | ||
- **A replacement for API docs.** A RESTyped spec will help you get the **routes** and **types** right, but doesn't provide the **context** or say anything about the **content** of API requests and responses. | ||
## Popular APIs to try out | ||
- Giphy API: [`restyped-giphy-api`](https://github.com/rawrmaan/restyped-giphy-api) |
// RESTyped implementations should take a type parameter that | ||
// extends Base | ||
export interface RestypeBase { | ||
export interface RestypedBase { | ||
[route: string]: any | ||
} | ||
export interface RestypeRoute { | ||
export interface RestypedRoute { | ||
params: any | ||
@@ -17,7 +17,7 @@ query: any | ||
// not cause errors when an invalid route is defined or called | ||
export interface RestypeIndexedBase { | ||
export interface RestypedIndexedBase { | ||
// e.g. '/orders' | ||
[route: string]: { | ||
// 'GET' | 'POST' | 'PUT' | 'PATCH' | 'HEAD' | 'DELETE' | 'OPTIONS' | ||
[method: string]: RestypeRoute | ||
[method: string]: RestypedRoute | ||
} | ||
@@ -24,0 +24,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
33346
1
159