Skip to content

Commit 61bf4c8

Browse files
committed
First commit
0 parents  commit 61bf4c8

21 files changed

+23244
-0
lines changed

.eslintrc.cjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
root: true,
3+
env: { browser: true, es2020: true },
4+
extends: [
5+
'eslint:recommended',
6+
'plugin:@typescript-eslint/recommended',
7+
'plugin:react-hooks/recommended',
8+
],
9+
ignorePatterns: ['dist', '.eslintrc.cjs'],
10+
parser: '@typescript-eslint/parser',
11+
plugins: ['react-refresh'],
12+
rules: {
13+
'react-refresh/only-export-components': [
14+
'warn',
15+
{ allowConstantExport: true },
16+
],
17+
},
18+
}

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
26+
# amplify
27+
.amplify
28+
amplify_outputs*
29+
amplifyconfiguration*

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# React + TypeScript + Vite
2+
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+
Currently, two official plugins are available:
6+
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9+
10+
## Expanding the ESLint configuration
11+
12+
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
13+
14+
- Configure the top-level `parserOptions` property like this:
15+
16+
```js
17+
export default {
18+
// other rules...
19+
parserOptions: {
20+
ecmaVersion: 'latest',
21+
sourceType: 'module',
22+
project: ['./tsconfig.json', './tsconfig.node.json'],
23+
tsconfigRootDir: __dirname,
24+
},
25+
}
26+
```
27+
28+
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
29+
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
30+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list

amplify/auth/resource.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineAuth } from '@aws-amplify/backend';
2+
3+
/**
4+
* Define and configure your auth resource
5+
* @see https://docs.amplify.aws/gen2/build-a-backend/auth
6+
*/
7+
export const auth = defineAuth({
8+
loginWith: {
9+
email: true,
10+
},
11+
});

amplify/backend.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineBackend } from '@aws-amplify/backend';
2+
import { auth } from './auth/resource';
3+
import { data } from './data/resource';
4+
5+
/**
6+
* @see https://docs.amplify.aws/react/build-a-backend/ to add storage, functions, and more
7+
*/
8+
defineBackend({
9+
auth,
10+
data,
11+
});

amplify/data/resource.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { type ClientSchema, a, defineData } from '@aws-amplify/backend';
2+
3+
/*== STEP 1 ===============================================================
4+
The section below creates a Todo database table with a "content" field. Try
5+
adding a new "isDone" field as a boolean. The authorization rule below
6+
specifies that any unauthenticated user can "create", "read", "update",
7+
and "delete" any "Todo" records.
8+
=========================================================================*/
9+
const schema = a.schema({
10+
Todo: a
11+
.model({
12+
content: a.string(),
13+
})
14+
.authorization((allow) => [allow.guest()]),
15+
});
16+
17+
export type Schema = ClientSchema<typeof schema>;
18+
19+
export const data = defineData({
20+
schema,
21+
authorizationModes: {
22+
defaultAuthorizationMode: 'iam',
23+
},
24+
});
25+
26+
/*== STEP 2 ===============================================================
27+
Go to your frontend source code. From your client-side code, generate a
28+
Data client to make CRUDL requests to your table. (THIS SNIPPET WILL ONLY
29+
WORK IN THE FRONTEND CODE FILE.)
30+
31+
Using JavaScript or Next.js React Server Components, Middleware, Server
32+
Actions or Pages Router? Review how to generate Data clients for those use
33+
cases: https://docs.amplify.aws/gen2/build-a-backend/data/connect-to-API/
34+
=========================================================================*/
35+
36+
/*
37+
"use client"
38+
import { generateClient } from "aws-amplify/data";
39+
import type { Schema } from "@/amplify/data/resource";
40+
41+
const client = generateClient<Schema>() // use this Data client for CRUDL requests
42+
*/
43+
44+
/*== STEP 3 ===============================================================
45+
Fetch records from the database and use them in your frontend component.
46+
(THIS SNIPPET WILL ONLY WORK IN THE FRONTEND CODE FILE.)
47+
=========================================================================*/
48+
49+
/* For example, in a React component, you can use this snippet in your
50+
function's RETURN statement */
51+
// const { data: todos } = await client.models.Todo.list()
52+
53+
// return <ul>{todos.map(todo => <li key={todo.id}>{todo.content}</li>)}</ul>

amplify/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

amplify/tsconfig.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2022",
4+
"module": "es2022",
5+
"moduleResolution": "bundler",
6+
"resolveJsonModule": true,
7+
"esModuleInterop": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"strict": true,
10+
"skipLibCheck": true,
11+
"paths": {
12+
"$amplify/*": [
13+
"../.amplify/generated/*"
14+
]
15+
}
16+
}
17+
}

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React + TS</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)