Skip to content

Commit d25b709

Browse files
authored
Initial commit
0 parents  commit d25b709

25 files changed

+27626
-0
lines changed

.eslintrc.cjs

+18
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

+29
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*

CODE_OF_CONDUCT.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Code of Conduct
2+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4+
opensource-codeofconduct@amazon.com with any additional questions or comments.

CONTRIBUTING.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Contributing Guidelines
2+
3+
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4+
documentation, we greatly value feedback and contributions from our community.
5+
6+
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7+
information to effectively respond to your bug report or contribution.
8+
9+
10+
## Reporting Bugs/Feature Requests
11+
12+
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13+
14+
When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already
15+
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16+
17+
* A reproducible test case or series of steps
18+
* The version of our code being used
19+
* Any modifications you've made relevant to the bug
20+
* Anything unusual about your environment or deployment
21+
22+
23+
## Contributing via Pull Requests
24+
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
25+
26+
1. You are working against the latest source on the *main* branch.
27+
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
28+
3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
29+
30+
To send us a pull request, please:
31+
32+
1. Fork the repository.
33+
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34+
3. Ensure local tests pass.
35+
4. Commit to your fork using clear commit messages.
36+
5. Send us a pull request, answering any default questions in the pull request interface.
37+
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
38+
39+
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
40+
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
41+
42+
43+
## Finding contributions to work on
44+
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.
45+
46+
47+
## Code of Conduct
48+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
50+
opensource-codeofconduct@amazon.com with any additional questions or comments.
51+
52+
53+
## Security issue notifications
54+
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
55+
56+
57+
## Licensing
58+
59+
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.

LICENSE

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
MIT No Attribution
2+
3+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
13+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
15+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17+

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## AWS Amplify React+Vite Starter Template
2+
3+
This repository provides a starter template for creating applications using React+Vite and AWS Amplify, emphasizing easy setup for authentication, API, and database capabilities.
4+
5+
## Overview
6+
7+
This template equips you with a foundational React application integrated with AWS Amplify, streamlined for scalability and performance. It is ideal for developers looking to jumpstart their project with pre-configured AWS services like Cognito, AppSync, and DynamoDB.
8+
9+
## Features
10+
11+
- **Authentication**: Setup with Amazon Cognito for secure user authentication.
12+
- **API**: Ready-to-use GraphQL endpoint with AWS AppSync.
13+
- **Database**: Real-time database powered by Amazon DynamoDB.
14+
15+
## Deploying to AWS
16+
17+
For detailed instructions on deploying your application, refer to the [deployment section](https://docs.amplify.aws/react/start/quickstart/#deploy-a-fullstack-app-to-aws) of our documentation.
18+
19+
## Security
20+
21+
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
22+
23+
## License
24+
25+
This library is licensed under the MIT-0 License. See the LICENSE file.

amplify.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: 1
2+
backend:
3+
phases:
4+
build:
5+
commands:
6+
- npm ci --cache .npm --prefer-offline
7+
- npx ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID
8+
frontend:
9+
phases:
10+
build:
11+
commands:
12+
- npm run build
13+
artifacts:
14+
baseDirectory: dist
15+
files:
16+
- '**/*'
17+
cache:
18+
paths:
19+
- .npm/**/*
20+
- node_modules/**/*

amplify/auth/resource.ts

+11
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

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
});

amplify/data/resource.ts

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 user authenticated via an API key can "create", "read",
7+
"update", 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.publicApiKey()]),
15+
});
16+
17+
export type Schema = ClientSchema<typeof schema>;
18+
19+
export const data = defineData({
20+
schema,
21+
authorizationModes: {
22+
defaultAuthorizationMode: "apiKey",
23+
// API Key is used for a.allow.public() rules
24+
apiKeyAuthorizationMode: {
25+
expiresInDays: 30,
26+
},
27+
},
28+
});
29+
30+
/*== STEP 2 ===============================================================
31+
Go to your frontend source code. From your client-side code, generate a
32+
Data client to make CRUDL requests to your table. (THIS SNIPPET WILL ONLY
33+
WORK IN THE FRONTEND CODE FILE.)
34+
35+
Using JavaScript or Next.js React Server Components, Middleware, Server
36+
Actions or Pages Router? Review how to generate Data clients for those use
37+
cases: https://docs.amplify.aws/gen2/build-a-backend/data/connect-to-API/
38+
=========================================================================*/
39+
40+
/*
41+
"use client"
42+
import { generateClient } from "aws-amplify/data";
43+
import type { Schema } from "@/amplify/data/resource";
44+
45+
const client = generateClient<Schema>() // use this Data client for CRUDL requests
46+
*/
47+
48+
/*== STEP 3 ===============================================================
49+
Fetch records from the database and use them in your frontend component.
50+
(THIS SNIPPET WILL ONLY WORK IN THE FRONTEND CODE FILE.)
51+
=========================================================================*/
52+
53+
/* For example, in a React component, you can use this snippet in your
54+
function's RETURN statement */
55+
// const { data: todos } = await client.models.Todo.list()
56+
57+
// return <ul>{todos.map(todo => <li key={todo.id}>{todo.content}</li>)}</ul>

amplify/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

amplify/tsconfig.json

+17
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

+13
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)