-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'folder-structure' into main
- Loading branch information
Showing
16 changed files
with
259 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 16,7 @@ out/ | |
|
||
# production | ||
build | ||
dist | ||
|
||
# misc | ||
.DS_Store | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -1,6 1,21 @@ | ||
{ | ||
"name": "safe-nappi", | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"scripts": { | ||
"build": "tsup", | ||
"watch": "tsup --watch" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "18.0.5", | ||
"next": "12.2.2", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"tsup": "^6.1.3" | ||
}, | ||
"peerDependencies": { | ||
"next": "12.2.2", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0" | ||
} | ||
} | ||
} |
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 @@ | ||
export type ApiResponse<T extends string> = 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,4 @@ | ||
export {nappiPlugin} from "./plugin"; | ||
export type {InferResponse} from "./inferResponse"; | ||
export type {ApiResponse} from "./ApiResponse"; | ||
export * from "./real-types"; |
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,12 1,9 @@ | ||
interface SampleApiPathMap { | ||
"/api/user": { data: { user: { id: number; name: string } } }; | ||
[key: `/api/some/${number}/dynamic`]: { dynamic: boolean }; | ||
} | ||
export const jsonFetch = async (path: string, query?: Record<string, string>): Promise<unknown> => { | ||
if (query) { | ||
const queryObj = new URLSearchParams(query); | ||
path = `?${queryObj.toString()}`; | ||
} | ||
|
||
export const jsonFetch = async <T extends keyof SampleApiPathMap>( | ||
path: T | ||
): Promise<SampleApiPathMap[T]> => { | ||
const res = await fetch(path); | ||
const data = await res.json(); | ||
return data as SampleApiPathMap[T]; | ||
return await res.json(); | ||
}; |
Oops, something went wrong.