Skip to content

Commit 15aa872

Browse files
authored
feat: add amplify-adapter-react-router package (#40)
* feat(amplify-adapter-react-router): add initial implementation * feat(todo-app): add initial implementation of Todo app with React Router and AWS Amplify * fix(todo-app): update authorization to require authenticated users * chore: add amplify.yml for todo-app backend and frontend builds and hosting * chore: update amplify.yml to correct build and artifact paths * chore(todo-app): remove amplify_outputs.json file * chore: fix typo in amplify.yml for node-linker configuration * chore(todo-app): update .gitignore and package.json for amplify outputs and server start script * fix(todo-app): use apiKey authorization mode * fix: add prebuild script to generate empty amplify_outputs.json * fix(todo-app): replace prebuild script with TypeScript version * fix(todo-app): remove Dockerfile as it is no longer needed * add changeset for amplify-adapter-react-router
1 parent 4e13249 commit 15aa872

File tree

35 files changed

+15606
-2346
lines changed

35 files changed

+15606
-2346
lines changed

.changeset/beige-walls-invent.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"amplify-adapter-react-router": minor
3+
---
4+
5+
feat: add amplify-adapter-react-router pacakge

amplify.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: 1
2+
applications:
3+
- backend:
4+
phases:
5+
build:
6+
commands:
7+
- pwd
8+
- "ls -al"
9+
- echo "node-linker=hoisted" > ../../.npmrc
10+
- corepack enable
11+
- pnpm install --frozen-lockfile
12+
- pnpm exec ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID
13+
frontend:
14+
phases:
15+
build:
16+
commands:
17+
- pnpm --workspace-root build
18+
artifacts:
19+
baseDirectory: .amplify-hosting
20+
files:
21+
- "**/*"
22+
cache:
23+
paths:
24+
- node_modules/**/*
25+
buildPath: examples/todo-app
26+
appRoot: examples/todo-app

examples/todo-app/.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.react-router
2+
build
3+
node_modules
4+
README.md

examples/todo-app/.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.DS_Store
2+
/node_modules/
3+
4+
# React Router
5+
/.react-router/
6+
/build/
7+
8+
# Amplify
9+
/.amplify/
10+
/.amplify-hosting/
11+
amplify_outputs.json
12+

examples/todo-app/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Todo app using React Router SSR and AWS Amplify
2+
3+
A Todo application using React Router and AWS Amplify.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineAuth } from '@aws-amplify/backend';
2+
3+
export const auth = defineAuth({
4+
loginWith: {
5+
email: true
6+
}
7+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineBackend } from '@aws-amplify/backend';
2+
import { auth } from './auth/resource';
3+
import { data } from './data/resource';
4+
5+
defineBackend({
6+
auth,
7+
data
8+
});
9+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { a, defineData, type ClientSchema } from '@aws-amplify/backend';
2+
3+
const schema = a.schema({
4+
Todo: a.model({
5+
content: a.string(),
6+
isDone: a.boolean()
7+
})
8+
.authorization(allow => [allow.publicApiKey()])
9+
});
10+
11+
export type Schema = ClientSchema<typeof schema>;
12+
export const data = defineData({
13+
schema,
14+
authorizationModes: {
15+
defaultAuthorizationMode: 'apiKey',
16+
}
17+
});
18+

examples/todo-app/app/app.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@import "tailwindcss";
2+
3+
@theme {
4+
--font-sans: "Inter", ui-sans-serif, system-ui, sans-serif,
5+
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
6+
}
7+
8+
html,
9+
body {
10+
@apply bg-white dark:bg-gray-950;
11+
12+
@media (prefers-color-scheme: dark) {
13+
color-scheme: dark;
14+
}
15+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { TodoListItem, type TodoListItemProps } from "./TodoListItem";
2+
3+
export type TodoListProps = {
4+
items: TodoListItemProps["item"][];
5+
};
6+
7+
export function TodoList({ items }: TodoListProps) {
8+
if (items.length === 0) {
9+
return <p>No items</p>;
10+
}
11+
12+
return (
13+
<ul className="divide-y divide-gray-200 border-1 border-gray-200 rounded-xl">
14+
{items.map((item) => (
15+
<TodoListItem key={item.id} item={item} />
16+
))}
17+
</ul>
18+
);
19+
}

0 commit comments

Comments
 (0)