Added amplify
This commit is contained in:
@@ -21,3 +21,8 @@
|
|||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
|
# amplify
|
||||||
|
.amplify
|
||||||
|
amplify_outputs*
|
||||||
|
amplifyconfiguration*
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { defineAuth } from '@aws-amplify/backend';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define and configure your auth resource
|
||||||
|
* @see https://docs.amplify.aws/gen2/build-a-backend/auth
|
||||||
|
*/
|
||||||
|
export const auth = defineAuth({
|
||||||
|
loginWith: {
|
||||||
|
email: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { defineBackend } from '@aws-amplify/backend';
|
||||||
|
import { auth } from './auth/resource';
|
||||||
|
import { data } from './data/resource';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://docs.amplify.aws/react/build-a-backend/ to add storage, functions, and more
|
||||||
|
*/
|
||||||
|
defineBackend({
|
||||||
|
auth,
|
||||||
|
data,
|
||||||
|
});
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { type ClientSchema, a, defineData } from '@aws-amplify/backend';
|
||||||
|
|
||||||
|
/*== STEP 1 ===============================================================
|
||||||
|
The section below creates a Todo database table with a "content" field. Try
|
||||||
|
adding a new "isDone" field as a boolean. The authorization rule below
|
||||||
|
specifies that any unauthenticated user can "create", "read", "update",
|
||||||
|
and "delete" any "Todo" records.
|
||||||
|
=========================================================================*/
|
||||||
|
const schema = a.schema({
|
||||||
|
Todo: a
|
||||||
|
.model({
|
||||||
|
content: a.string(),
|
||||||
|
})
|
||||||
|
.authorization((allow) => [allow.guest()]),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type Schema = ClientSchema<typeof schema>;
|
||||||
|
|
||||||
|
export const data = defineData({
|
||||||
|
schema,
|
||||||
|
authorizationModes: {
|
||||||
|
defaultAuthorizationMode: 'identityPool',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/*== STEP 2 ===============================================================
|
||||||
|
Go to your frontend source code. From your client-side code, generate a
|
||||||
|
Data client to make CRUDL requests to your table. (THIS SNIPPET WILL ONLY
|
||||||
|
WORK IN THE FRONTEND CODE FILE.)
|
||||||
|
|
||||||
|
Using JavaScript or Next.js React Server Components, Middleware, Server
|
||||||
|
Actions or Pages Router? Review how to generate Data clients for those use
|
||||||
|
cases: https://docs.amplify.aws/gen2/build-a-backend/data/connect-to-API/
|
||||||
|
=========================================================================*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
"use client"
|
||||||
|
import { generateClient } from "aws-amplify/data";
|
||||||
|
import type { Schema } from "@/amplify/data/resource";
|
||||||
|
|
||||||
|
const client = generateClient<Schema>() // use this Data client for CRUDL requests
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*== STEP 3 ===============================================================
|
||||||
|
Fetch records from the database and use them in your frontend component.
|
||||||
|
(THIS SNIPPET WILL ONLY WORK IN THE FRONTEND CODE FILE.)
|
||||||
|
=========================================================================*/
|
||||||
|
|
||||||
|
/* For example, in a React component, you can use this snippet in your
|
||||||
|
function's RETURN statement */
|
||||||
|
// const { data: todos } = await client.models.Todo.list()
|
||||||
|
|
||||||
|
// return <ul>{todos.map(todo => <li key={todo.id}>{todo.content}</li>)}</ul>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"type": "module"
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es2022",
|
||||||
|
"module": "es2022",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"paths": {
|
||||||
|
"$amplify/*": [
|
||||||
|
"../.amplify/generated/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+30671
-1240
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@
|
|||||||
"@testing-library/jest-dom": "^5.11.1",
|
"@testing-library/jest-dom": "^5.11.1",
|
||||||
"@testing-library/react": "^11.2.5",
|
"@testing-library/react": "^11.2.5",
|
||||||
"@testing-library/user-event": "^12.0.11",
|
"@testing-library/user-event": "^12.0.11",
|
||||||
|
"aws-amplify": "^6.17.0",
|
||||||
"bootstrap": "^5.0.0",
|
"bootstrap": "^5.0.0",
|
||||||
"immer": "9.0.6",
|
"immer": "9.0.6",
|
||||||
"ini": "2.0.0",
|
"ini": "2.0.0",
|
||||||
@@ -42,5 +43,14 @@
|
|||||||
"last 1 firefox version",
|
"last 1 firefox version",
|
||||||
"last 1 safari version"
|
"last 1 safari version"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@aws-amplify/backend": "^1.23.0",
|
||||||
|
"@aws-amplify/backend-cli": "^1.8.3",
|
||||||
|
"aws-cdk-lib": "^2.244.0",
|
||||||
|
"constructs": "^10.6.0",
|
||||||
|
"esbuild": "^0.28.0",
|
||||||
|
"tsx": "^4.22.4",
|
||||||
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user