-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
12 changed files
with
2,707 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
node_modules | ||
.yarn/* | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/plugins | ||
.DS_Store | ||
dist |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/prettierrc", | ||
"singleQuote": true, | ||
"semi": true, | ||
"printWidth": 80, | ||
"trailingComma": "all", | ||
"arrowParens": "avoid", | ||
"bracketSpacing": false, | ||
"useTabs": true, | ||
"quoteProps": "consistent" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["esbenp.prettier-vscode"] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
nodeLinker: node-modules | ||
|
||
yarnPath: .yarn/releases/yarn-3.2.1.cjs |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "@onehop/js", | ||
"version": "1.0.0", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"repository": "https://github.com/hopinc/hop-js.git", | ||
"author": "Alistair Smith <[email protected]>", | ||
"license": "MIT", | ||
"packageManager": "[email protected]", | ||
"devDependencies": { | ||
"prettier": "^2.6.2", | ||
"tsup": "^5.12.8", | ||
"typescript": "^4.6.4" | ||
} | ||
} |
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 +1 @@ | ||
export {}; | ||
// |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import {Method, Responses} from './types'; | ||
|
||
export type Endpoint< | ||
M extends Method, | ||
Path extends string, | ||
Res, | ||
Body = never, | ||
> = { | ||
method: M; | ||
path: Path; | ||
res: Res; | ||
body: Body; | ||
}; | ||
|
||
export type Endpoints = | ||
| Endpoint<'GET', '/v1/pipe/rooms', Responses.PIPE.GET_ROOMS> | ||
| Endpoint< | ||
'POST', | ||
'/v1/pipe/rooms', | ||
Responses.PIPE.CREATE_ROOM, | ||
{ | ||
/** | ||
* The name of the room | ||
*/ | ||
name: string; | ||
|
||
/** | ||
* Any information attatched to the room | ||
*/ | ||
metadata: unknown; | ||
} | ||
>; | ||
|
||
export type SuccessfulAPIResposne<T> = { | ||
success: true; | ||
data: T; | ||
}; | ||
|
||
export type ErroredAPIResponse = { | ||
success: false; | ||
error: { | ||
code: string; | ||
message: string; | ||
}; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; | ||
|
||
export namespace Responses { | ||
export namespace PIPE { | ||
export interface Room { | ||
id: string; | ||
name: string; | ||
created_at: number; | ||
} | ||
|
||
export interface GET_ROOMS { | ||
rooms: Room[]; | ||
} | ||
|
||
export interface CREATE_ROOM { | ||
room: Room; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export type ExtractRouteParams<T extends string> = string extends T | ||
? string | ||
: T extends `${string}:${infer Param}/${infer Rest}` | ||
? Param | keyof ExtractRouteParams<Rest> | ||
: T extends `${string}:${infer Param}` | ||
? Param | ||
: never; |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {defineConfig} from 'tsup'; | ||
|
||
export default defineConfig({ | ||
entry: ['src/index.ts'], | ||
dts: true, | ||
}); |
Oops, something went wrong.