Skip to content

Commit baeaffe

Browse files
chore(_official-tutorial): cleanup example (#182)
1 parent 4e825eb commit baeaffe

File tree

8 files changed

+22
-50
lines changed

8 files changed

+22
-50
lines changed

_official-tutorial/app/root.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from "react";
1+
import type { LoaderArgs } from "@remix-run/node";
22
import { redirect } from "@remix-run/node";
33
import {
44
Form,
@@ -15,13 +15,14 @@ import {
1515
useNavigation,
1616
useFetchers,
1717
} from "@remix-run/react";
18-
import type { DataFunctionArgs } from "@remix-run/node";
18+
import * as React from "react";
1919

20-
import { createEmptyContact, getContacts, type ContactRecord } from "./data";
21-
import ErrorPage from "./error-page";
22-
import appStylesHref from "./app.css";
20+
import appStylesHref from "~/app.css";
21+
import type { ContactRecord } from "~/data";
22+
import { createEmptyContact, getContacts } from "~/data";
23+
import ErrorPage from "~/error-page";
2324

24-
export async function loader({ request }: DataFunctionArgs) {
25+
export async function loader({ request }: LoaderArgs) {
2526
const url = new URL(request.url);
2627
const q = url.searchParams.get("q") || undefined;
2728
const contacts = await getContacts(q);

_official-tutorial/app/routes/contacts.$contactId.destroy.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import type { ActionArgs } from "@remix-run/node";
12
import { redirect } from "@remix-run/node";
2-
import type { DataFunctionArgs } from "@remix-run/node";
33
import invariant from "tiny-invariant";
44

5-
import { deleteContact } from "../data";
5+
import { deleteContact } from "~/data";
66

77
// This route is interesting because it doesn't export a component but redirects
88
// once the action is complete. Routes don't have to have components!
9-
export async function action({ params }: DataFunctionArgs) {
9+
export async function action({ params }: ActionArgs) {
1010
invariant(params.contactId, "Missing contactId param");
1111
await deleteContact(params.contactId);
1212
return redirect("/");

_official-tutorial/app/routes/contacts.$contactId.edit.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import invariant from "tiny-invariant";
2-
import type { DataFunctionArgs } from "@remix-run/node";
1+
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
32
import { redirect } from "@remix-run/node";
43
import {
54
Form,
65
useLoaderData,
76
useNavigate,
87
useNavigation,
98
} from "@remix-run/react";
9+
import invariant from "tiny-invariant";
1010

1111
import { getContact, updateContact } from "~/data";
1212

13-
export async function loader({ params }: DataFunctionArgs) {
13+
export async function loader({ params }: LoaderArgs) {
1414
invariant(params.contactId, "missing contactId param");
1515
const contact = await getContact(params.contactId);
1616
if (!contact) {
@@ -21,7 +21,7 @@ export async function loader({ params }: DataFunctionArgs) {
2121
return contact;
2222
}
2323

24-
export async function action({ params, request }: DataFunctionArgs) {
24+
export async function action({ params, request }: ActionArgs) {
2525
invariant(params.contactId, "missing contactId param");
2626
const formData = await request.formData();
2727
await updateContact(params.contactId, {

_official-tutorial/app/routes/contacts.$contactId.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { DataFunctionArgs } from "@remix-run/node";
1+
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
22
import { Form, useFetcher, useLoaderData } from "@remix-run/react";
33
import invariant from "tiny-invariant";
44

55
import { updateContact, getContact, type ContactRecord } from "~/data";
66

7-
export async function loader({ params }: DataFunctionArgs) {
7+
export async function loader({ params }: LoaderArgs) {
88
// `invariant` is a little library that throws an error if the first argument
99
// is falsy. It's useful in a TypeScript environment especially with Remix
1010
// because of `ErrorBoundary`. When errors are thrown from loaders (by
@@ -24,7 +24,7 @@ export async function loader({ params }: DataFunctionArgs) {
2424
return contact;
2525
}
2626

27-
export async function action({ params, request }: DataFunctionArgs) {
27+
export async function action({ params, request }: ActionArgs) {
2828
invariant(params.contactId, "missing contactId param");
2929
const formData = await request.formData();
3030
const favorite = formData.get("favorite") === "true";

_official-tutorial/package.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
"sideEffects": false,
44
"scripts": {
55
"build": "remix build",
6-
"dev": "concurrently \"NODE_ENV=development remix dev\" \"NODE_ENV=development nodemon --watch server.js\"",
7-
"start": "npm run build && node server.js",
6+
"dev": "remix dev",
7+
"start": "remix-serve build",
88
"typecheck": "tsc"
99
},
1010
"dependencies": {
11-
"@remix-run/express": "^1.13.0",
1211
"@remix-run/node": "~1.14.2",
1312
"@remix-run/react": "~1.14.2",
1413
"@remix-run/serve": "~1.14.2",
15-
"express": "^4.18.2",
1614
"isbot": "^3.6.5",
1715
"match-sorter": "^6.3.1",
1816
"react": "^18.2.0",
@@ -25,14 +23,10 @@
2523
"@remix-run/eslint-config": "~1.14.2",
2624
"@types/react": "^18.0.25",
2725
"@types/react-dom": "^18.0.8",
28-
"concurrently": "^7.6.0",
2926
"eslint": "^8.27.0",
30-
"nodemon": "^2.0.20",
31-
"prettier": "^2.8.4",
3227
"typescript": "^4.8.4"
3328
},
3429
"engines": {
3530
"node": ">=14"
36-
},
37-
"prettier": {}
31+
}
3832
}

_official-tutorial/remix.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/** @type {import('@remix-run/dev').AppConfig} */
22
module.exports = {
3-
ignoredRouteFiles: ["**/.*"],
43
future: {
54
unstable_dev: true,
65
},
6+
ignoredRouteFiles: ["**/.*"],
77
// appDirectory: "app",
88
// assetsBuildDirectory: "public/build",
99
// serverBuildPath: "build/index.js",

_official-tutorial/server.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

_official-tutorial/tsconfig.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
{
2-
"include": [
3-
"remix.env.d.ts",
4-
"**/*.ts",
5-
"**/*.tsx",
6-
"app/contacts.js",
7-
"app/routes/.contacts.$contactId.destroy.tsx"
8-
],
2+
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
93
"compilerOptions": {
104
"lib": ["DOM", "DOM.Iterable", "ES2019"],
115
"isolatedModules": true,

0 commit comments

Comments
 (0)