Skip to content

Commit 45003ae

Browse files
committed
add a backend
1 parent b5c7dba commit 45003ae

File tree

6 files changed

+21208
-0
lines changed

6 files changed

+21208
-0
lines changed

amplify/auth/resource.ts

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+
});

amplify/backend.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineBackend } from '@aws-amplify/backend';
2+
import { auth } from './auth/resource';
3+
import { data } from './data/resource';
4+
5+
const backend = defineBackend({
6+
auth,
7+
data,
8+
});
9+
10+
backend.data.resources.cfnResources.amplifyDynamoDbTables.SessionStorage.timeToLiveAttribute =
11+
{
12+
attributeName: 'ttl',
13+
enabled: true,
14+
};

amplify/data/resource.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { type ClientSchema, a, defineData } from '@aws-amplify/backend';
2+
3+
const templateTypes = ['NHS_APP', 'SMS', 'EMAIL', 'LETTER'] as const;
4+
5+
const SessionStorageModel = {
6+
id: a.string().required(),
7+
templateType: a.enum([...templateTypes, 'UNKNOWN']),
8+
nhsAppTemplateName: a.string().required(),
9+
nhsAppTemplateMessage: a.string().required(),
10+
smsTemplateName: a.string(),
11+
smsTemplateMessage: a.string(),
12+
ttl: a.integer().required(),
13+
};
14+
15+
const TemplateStorageModel = {
16+
id: a.string().required(),
17+
name: a.string().required(),
18+
type: a.enum(templateTypes),
19+
version: a.integer().required(),
20+
fields: a.customType({
21+
content: a.string().required(),
22+
}),
23+
};
24+
25+
const schema = a.schema({
26+
SessionStorage: a
27+
.model(SessionStorageModel)
28+
.authorization((allow) => [allow.guest()]),
29+
TemplateStorage: a
30+
.model(TemplateStorageModel)
31+
.authorization((allow) => [allow.guest()]),
32+
});
33+
34+
export type Schema = ClientSchema<typeof schema>;
35+
36+
export const data = defineData({
37+
schema,
38+
authorizationModes: {
39+
defaultAuthorizationMode: 'iam',
40+
},
41+
});

0 commit comments

Comments
 (0)