-
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.
- Loading branch information
Showing
19 changed files
with
131 additions
and
25 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 |
---|---|---|
|
@@ -46,7 +46,6 @@ yarn-error.log* | |
|
||
# typescript | ||
*.tsbuildinfo | ||
dist/ | ||
|
||
# turbo | ||
.turbo | ||
|
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 |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
|
||
# production | ||
/build | ||
/dist | ||
/out | ||
|
||
# misc | ||
|
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,6 +1,5 @@ | ||
node_modules/ | ||
.expo/ | ||
dist/ | ||
npm-debug.* | ||
*.jks | ||
*.p8 | ||
|
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { createTRPCReact, httpBatchLink, loggerLink } from '@trpc/react-query' | ||
import superjson from 'superjson' | ||
|
||
import type { Router } from '@splitter/api/router' | ||
|
||
import env, { isProductionEnv } from '@/services/env' | ||
|
||
const protocol = isProductionEnv(env.ENV) ? 'https' : 'http' | ||
const host = isProductionEnv(env.ENV) ? env.API_HOST : env.DEBUGGER_HOST | ||
const port = env.API_PORT | ||
const pathname = '/trpc' | ||
|
||
const TRPC_API_URL = `${protocol}://${host}:${port}${pathname}` | ||
|
||
export const api = createTRPCReact<Router>() | ||
|
||
export const TRPCProvider = api.Provider | ||
|
||
export const createTRPCClient = () => | ||
api.createClient({ | ||
transformer: superjson, | ||
links: [ | ||
loggerLink({ | ||
colorMode: 'ansi', | ||
enabled: (opts) => opts.direction === 'down' && !opts.result, | ||
}), | ||
httpBatchLink({ | ||
url: TRPC_API_URL, | ||
headers() { | ||
const headers = new Map<string, string>() | ||
headers.set('x-trpc-source', 'expo-react') | ||
return Object.fromEntries(headers) | ||
}, | ||
}), | ||
], | ||
}) | ||
|
||
export { type RouterInputs, type RouterOutputs } from '@splitter/api/router' |
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,18 @@ | ||
import Constants from 'expo-constants' | ||
import z from 'zod' | ||
|
||
export function isProductionEnv(env: 'development' | 'production') { | ||
return env === 'production' | ||
} | ||
|
||
const schema = z.object({ | ||
ENV: z.union([z.literal('development'), z.literal('production')]), | ||
API_HOST: z.string(), | ||
API_PORT: z.string(), | ||
DEBUGGER_HOST: z.string(), | ||
}) | ||
|
||
export default schema.parse({ | ||
...Constants.expoConfig?.extra, | ||
DEBUGGER_HOST: Constants.expoConfig?.hostUri?.split(':').at(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,20 @@ | ||
import { useState } from 'react' | ||
|
||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
|
||
import { TRPCProvider, createTRPCClient } from '@/services/api' | ||
|
||
interface Props { | ||
children: JSX.Element | JSX.Element[] | ||
} | ||
|
||
export default function Provider({ children }: Props) { | ||
const [queryClient] = useState(() => new QueryClient()) | ||
const [trpcClient] = useState(() => createTRPCClient()) | ||
|
||
return ( | ||
<TRPCProvider client={trpcClient} queryClient={queryClient}> | ||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
</TRPCProvider> | ||
) | ||
} |
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 |
---|---|---|
|
@@ -9,5 +9,5 @@ | |
} | ||
}, | ||
"include": ["*.ts", "src"], | ||
"exclude": ["node_modules"] | ||
"exclude": ["node_modules", "build"] | ||
} |
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
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
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