Skip to content

Commit

Permalink
feat: recreate DB migration
Browse files Browse the repository at this point in the history
  • Loading branch information
windchime-yk committed Nov 16, 2024
1 parent df18c2f commit 729b5a2
Show file tree
Hide file tree
Showing 15 changed files with 295 additions and 205 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@jsr:registry=https://npm.jsr.io
4 changes: 2 additions & 2 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export default async function handleRequest(
remixContext: EntryContext,
// This is ignored so we can keep it in the template for visibility. Feel
// free to delete this parameter in your app if you're not using it!
// eslint-disable-next-line @typescript-eslint/no-unused-vars
loadContext: AppLoadContext,
_loadContext: AppLoadContext,
) {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), ABORT_DELAY);
Expand All @@ -37,6 +36,7 @@ export default async function handleRequest(
// Log streaming rendering errors from inside the shell
console.error(error);
}
// biome-ignore lint/style/noParameterAssign: フレームワークの既存コードのため
responseStatusCode = 500;
},
},
Expand Down
87 changes: 76 additions & 11 deletions app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { MetaFunction } from "@remix-run/cloudflare";
import type { AppType } from "../../server";
import {hc} from 'hono/client';
import { useLoaderData } from "@remix-run/react";
import { hc } from "hono/client";
import type { AppType } from "../../server";

export const meta: MetaFunction = () => {
return [
Expand All @@ -11,14 +11,28 @@ export const meta: MetaFunction = () => {
};

export const loader = async () => {
const client = hc<AppType>('http://localhost:5173');
const res = await client.api.movie.$get();
const movies = await res.json();
return movies;
}
const client = hc<AppType>("http://localhost:5173");
const moviesResponse = await client.api.movies.$get();
const movies = await moviesResponse.json();
const theatersResponse = await client.api.theaters.$get();
const theaters = await theatersResponse.json();
const creatersCountriesResponse = await client.api.creaters_countries.$get();
const creatersCountries = await creatersCountriesResponse.json();
const screeningFormatsResponse = await client.api.screening_formats.$get();
const screeningFormats = await screeningFormatsResponse.json();
const movieFormatsResponse = await client.api.movie_formats.$get();
const movieFormats = await movieFormatsResponse.json();
return {
movies,
theaters,
creatersCountries,
screeningFormats,
movieFormats,
};
};

export default function Index() {
const movies = useLoaderData<typeof loader>();
const data = useLoaderData<typeof loader>();

return (
<html lang="ja">
Expand All @@ -28,9 +42,60 @@ export default function Index() {
</head>
<body>
<h1 className="text-3xl font-bold underline">Hello World</h1>
<ul>
{movies.map((movie) => (<li key={movie.id}>{movie.title}</li>))}
</ul>
<section>
<h2 className="text-2xl font-bold underline">Movies</h2>
<ul>
{data.movies.map((movie) => (
<li key={movie.id}>
{movie.title}({movie.id})、{movie.theater.name}(
{movie.theaterId})、{movie.createrCountry.name}(
{movie.createrCountryId})、{movie.screeningFormat.name}(
{movie.screeningFormatId})、{movie.movieFormat.name}(
{movie.movieFormatId})
</li>
))}
</ul>
</section>
<section>
<h2 className="text-2xl font-bold underline">Theaters</h2>
<ul>
{data.theaters.map((theater) => (
<li key={theater.id}>
{theater.name}({theater.id})
</li>
))}
</ul>
</section>
<section>
<h2 className="text-2xl font-bold underline">Creaters Countries</h2>
<ul>
{data.creatersCountries.map((createrCountry) => (
<li key={createrCountry.id}>
{createrCountry.name}({createrCountry.id})
</li>
))}
</ul>
</section>
<section>
<h2 className="text-2xl font-bold underline">Screening Formats</h2>
<ul>
{data.screeningFormats.map((screeningFormat) => (
<li key={screeningFormat.id}>
{screeningFormat.name}({screeningFormat.id})
</li>
))}
</ul>
</section>
<section>
<h2 className="text-2xl font-bold underline">Movie Formats</h2>
<ul>
{data.movieFormats.map((movieFormat) => (
<li key={movieFormat.id}>
{movieFormat.name}({movieFormat.id})
</li>
))}
</ul>
</section>
</body>
</html>
);
Expand Down
8 changes: 4 additions & 4 deletions functions/[[path]].ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import handle from 'hono-remix-adapter/cloudflare-pages'
import * as build from '../build/server'
import server from '../server'
import handle from "hono-remix-adapter/cloudflare-pages";
import * as build from "../build/server";
import server from "../server";

export const onRequest = handle(build, server)
export const onRequest = handle(build, server);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@remix-run/cloudflare": "^2.13.1",
"@remix-run/cloudflare-pages": "^2.13.1",
"@remix-run/react": "^2.13.1",
"@std/ulid": "npm:@jsr/[email protected]",
"@tidbcloud/prisma-adapter": "^5.20.0",
"@tidbcloud/serverless": "^0.2.0",
"hono": "^4.6.8",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 0 additions & 30 deletions prisma/migrations/20241030130225_init/migration.sql

This file was deleted.

62 changes: 0 additions & 62 deletions prisma/migrations/20241030143918_init/migration.sql

This file was deleted.

65 changes: 0 additions & 65 deletions prisma/migrations/20241030144158_init/migration.sql

This file was deleted.

Loading

0 comments on commit 729b5a2

Please sign in to comment.