Skip to content

Commit

Permalink
Consolidate database schemas (#13)
Browse files Browse the repository at this point in the history
* consolidate schemas

* lint fix

* typecheck + prettier

* bigint
  • Loading branch information
thatguyinabeanie authored Nov 11, 2024
1 parent 38d6a68 commit 9fd1f34
Show file tree
Hide file tree
Showing 30 changed files with 1,272 additions and 1,480 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,22 @@
"kalos",
"nitropack",
"paldea",
"preconfigured",
"Pressable",
"prettiercache",
"sinnoh",
"sluggable",
"Solito",
"subrouters",
"Supabase",
"thatguyinabenaie",
"tsbuildinfo",
"tseslint",
"Turborepo",
"typesafe",
"unauthed",
"unova",
"unviable",
"Ursaluna"
],
"coverage-gutters.showGutterCoverage": false,
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ In order to get Next-Auth to work with Expo, you must either:

In [apps/auth-proxy](./apps/auth-proxy) you can find a Nitro server that proxies OAuth requests. By deploying this and setting the `AUTH_REDIRECT_PROXY_URL` environment variable to the URL of this proxy, you can get OAuth working in preview deployments and development for Expo apps. See more deployment instructions in the [auth proxy README](./apps/auth-proxy/README.md).

By using the proxy server, the Next.js apps will forward any auth requests to the proxy server, which will handle the OAuth flow and then redirect back to the Next.js app. This makes it easy to get OAuth working since you'll have a stable URL that is publically accessible and doesn't change for every deployment and doesn't rely on what port the app is running on. So if port 3000 is taken and your Next.js app starts at port 3001 instead, your auth should still work without having to reconfigure the OAuth provider.
By using the proxy server, the Next.js apps will forward any auth requests to the proxy server, which will handle the OAuth flow and then redirect back to the Next.js app. This makes it easy to get OAuth working since you'll have a stable URL that is publicly accessible and doesn't change for every deployment and doesn't rely on what port the app is running on. So if port 3000 is taken and your Next.js app starts at port 3001 instead, your auth should still work without having to reconfigure the OAuth provider.

#### Add your local IP to your OAuth provider

You can alternatively add your local IP (e.g. `192.168.x.y:$PORT`) to your OAuth provider. This may not be as reliable as your local IP may change when you change networks. Some OAuth providers may also only support a single callback URL for each app making this approach unviable for some providers (e.g. GitHub).
You can alternatively add your local IP (e.g. `192.168.x.y:$PORT`) to your OAuth provider. This may not be as reliable as your local IP may change when you change networks. Some OAuth providers may also only support a single callback URL for each app making this approach not viable for some providers (e.g. GitHub).

### 4a. When it's time to add a new UI component

Expand Down Expand Up @@ -160,7 +160,7 @@ Integrating Solito into this repo isn't hard, and there are a few [official temp

### Does this pattern leak backend code to my client applications?

No, it does not. The `api` package should only be a production dependency in the Next.js application where it's served. The Expo app, and all other apps you may add in the future, should only add the `api` package as a dev dependency. This lets you have full typesafety in your client applications, while keeping your backend code safe.
No, it does not. The `api` package should only be a production dependency in the Next.js application where it's served. The Expo app, and all other apps you may add in the future, should only add the `api` package as a dev dependency. This lets you have full type safety in your client applications, while keeping your backend code safe.

If you need to share runtime code between the client and server, such as input validation schemas, you can create a separate `shared` package for this and import it on both sides.

Expand Down
10 changes: 6 additions & 4 deletions apps/nextjs/src/app/server-actions/pokemon/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ export async function getPokemonTeams() {
export async function postPokemonTeam(
validatedTeam: ValidatedPokemon[],
metadata: PokePasteMetadata,
profileId?: bigint,
// profileId: bigint,
// gameId: bigint,
// formatId: bigint,
) {
const body = {
pokepasteId: metadata.id,
profileId: profileId,
profileId: 1n,
name: metadata.title,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
gameId: BigInt(1),
formatId: BigInt(1),
gameId: 1n,
formatId: 1n,
};

const pokemonTeamResult = await db
Expand Down
2 changes: 1 addition & 1 deletion packages/db/drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (!process.env.DATABASE_URL) {
const nonPoolingUrl = process.env.DATABASE_URL.replace(":6543", ":5432");

export default defineConfig({
schema: "./src/schema.ts",
schema: "./drizzle/schema.ts",
dialect: "postgresql",
dbCredentials: { url: nonPoolingUrl },
casing: "snake_case",
Expand Down
Loading

1 comment on commit 9fd1f34

@vercel
Copy link

@vercel vercel bot commented on 9fd1f34 Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.