-
Notifications
You must be signed in to change notification settings - Fork 30
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
10 changed files
with
90 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'telefunc' | ||
import type { User } from './auth/getUser' | ||
|
||
declare module 'telefunc' { | ||
namespace Telefunc { | ||
interface Context { | ||
user: null | User | ||
} | ||
} | ||
} |
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
8 changes: 4 additions & 4 deletions
8
examples/next/components/TodoList.jsx → examples/next/components/TodoList.tsx
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
18 changes: 16 additions & 2 deletions
18
examples/next/database/Todo.js → examples/next/database/Todo.ts
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,21 +1,35 @@ | ||
export { Todo } | ||
export type { TodoItem } | ||
|
||
const Todo = { | ||
findMany, | ||
createNew | ||
} | ||
|
||
type TodoItem = { | ||
text: string | ||
authorId: number | ||
} | ||
|
||
const database = (global.database = global.database || { | ||
todoItems: [ | ||
{ text: 'Buy milk', authorId: 0 }, | ||
{ text: 'Buy strawberries', authorId: 0 } | ||
] | ||
}) | ||
|
||
function findMany({ authorId }) { | ||
function findMany({ authorId }: { authorId: number }) { | ||
return database.todoItems.filter((todoItem) => todoItem.authorId === authorId) | ||
} | ||
|
||
function createNew({ text, authorId }) { | ||
function createNew({ text, authorId }: { text: string; authorId: number }) { | ||
database.todoItems.push({ text, authorId }) | ||
} | ||
|
||
declare global { | ||
var database: | ||
| undefined | ||
| { | ||
todoItems: TodoItem[] | ||
} | ||
} |
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,12 +1,14 @@ | ||
export default MyApp | ||
|
||
import { telefuncConfig } from 'telefunc/client' | ||
import type { AppProps } from 'next/app' | ||
import React from 'react' | ||
|
||
const isBrowser = typeof window !== 'undefined' | ||
if (isBrowser) { | ||
telefuncConfig.telefuncUrl = '/api/_telefunc' | ||
} | ||
|
||
function MyApp({ Component, pageProps }) { | ||
function MyApp({ Component, pageProps }: AppProps) { | ||
return <Component {...pageProps} /> | ||
} | ||
|
||
export default MyApp |
5 changes: 4 additions & 1 deletion
5
examples/next/pages/api/_telefunc.js → examples/next/pages/api/_telefunc.ts
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"module": "ES2020", | ||
"moduleResolution": "Node", | ||
"target": "ES2017", | ||
"lib": [ | ||
"DOM", | ||
"DOM.Iterable", | ||
"ESNext" | ||
], | ||
"jsx": "preserve", | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"allowJs": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"incremental": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true | ||
}, | ||
"include": [ | ||
"next-env.d.ts", | ||
"**/*.ts", | ||
"**/*.tsx" | ||
], | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |