-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c1dbbde
commit 08f015a
Showing
9 changed files
with
19 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,17 @@ | ||
/** | ||
* Example of const declaration | ||
*/ | ||
export const endpoints = { | ||
getUsers: '/users', | ||
getProducts: '/products', | ||
} | ||
export declare const endpoints | ||
|
||
/** | ||
* Example of interface declaration | ||
*/ | ||
export interface Order { | ||
export interface Order { | ||
orderId: number | ||
userId: number | ||
productIds: number[] | ||
} | ||
|
||
/** | ||
* Example of type declaration | ||
*/ | ||
export interface OrderResponse { | ||
export interface OrderResponse { | ||
success: boolean | ||
order: Order | ||
} | ||
|
||
/** | ||
* Example of function declaration | ||
*/ | ||
export async function createOrder(order: Order): Promise<OrderResponse> { | ||
return fetch(endpoints.getProducts, { | ||
method: 'POST', | ||
body: JSON.stringify(order), | ||
}).then(response => response.json()) as Promise<OrderResponse> | ||
} | ||
export declare function createOrder(order: Order): Promise<OrderResponse> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,10 @@ | ||
/** | ||
* Example of const declaration | ||
*/ | ||
export const apiKeys = { | ||
google: 'GOOGLE_API_KEY', | ||
facebook: 'FACEBOOK_API_KEY', | ||
} | ||
export declare const apiKeys | ||
|
||
/** | ||
* Example of interface declaration | ||
*/ | ||
export interface AuthResponse { | ||
export interface AuthResponse { | ||
token: string | ||
expiresIn: number | ||
} | ||
|
||
/** | ||
* Example of type declaration | ||
*/ | ||
export type AuthStatus = 'authenticated' | 'unauthenticated' | ||
|
||
/** | ||
* Example of function declaration | ||
*/ | ||
export function authenticate(user: string, password: string): Promise<AuthResponse> { | ||
return fetch('/auth/login', { | ||
method: 'POST', | ||
body: JSON.stringify({ user, password }), | ||
}).then(response => response.json()) as Promise<AuthResponse> | ||
} | ||
export declare function authenticate(user: string, password: string): Promise<AuthResponse> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,13 @@ | ||
/** | ||
* Example of const declaration | ||
*/ | ||
export const defaultHeaders = { | ||
'Content-Type': 'application/json', | ||
} | ||
export declare const defaultHeaders | ||
|
||
/** | ||
* Example of interface declaration | ||
*/ | ||
export interface Comment { | ||
export interface Comment { | ||
id: number | ||
postId: number | ||
body: string | ||
} | ||
|
||
/** | ||
* Example of type declaration | ||
*/ | ||
export interface CommentsResponse { | ||
export interface CommentsResponse { | ||
comments: Comment[] | ||
} | ||
|
||
/** | ||
* Example of function declaration | ||
*/ | ||
export function fetchComments(postId: number): Promise<CommentsResponse> { | ||
return fetch(`/posts/${postId}/comments`) | ||
.then(response => response.json()) as Promise<CommentsResponse> | ||
} | ||
export declare function fetchComments(postId: number): Promise<CommentsResponse> |