Skip to content

Commit

Permalink
Merge pull request #70 from jaydenchee97/feature
Browse files Browse the repository at this point in the history
update authorization rule for graphql and new lambda function
  • Loading branch information
jaydenchee97 authored Oct 26, 2024
2 parents 94c1f55 + 50f500c commit 8380428
Show file tree
Hide file tree
Showing 55 changed files with 27,029 additions and 4,149 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.expo
node_modules
amplify-codegen-temp\models\models
.github
.github
src\models\models
24 changes: 23 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,26 @@ amplify-gradle-config.json
amplifytools.xcconfig
.secret-*
**.sample
#amplify-do-not-edit-end
#amplify-do-not-edit-end

#amplify-do-not-edit-begin
amplify/\#current-cloud-backend
amplify/.config/local-*
amplify/logs
amplify/mock-data
amplify/mock-api-resources
amplify/backend/amplify-meta.json
amplify/backend/.temp
build/
dist/
node_modules/
aws-exports.js
awsconfiguration.json
amplifyconfiguration.json
amplifyconfiguration.dart
amplify-build-config.json
amplify-gradle-config.json
amplifytools.xcconfig
.secret-*
**.sample
#amplify-do-not-edit-end
1 change: 0 additions & 1 deletion App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Amplify.configure({

});


// Amplify.configure({awsExports});

export default function App() {
Expand Down
2 changes: 1 addition & 1 deletion amplify/.config/project-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"framework": "react-native",
"config": {
"SourceDir": "src",
"DistributionDir": "/",
"DistributionDir": "",
"BuildCommand": "npm.cmd run-script build",
"StartCommand": "npm.cmd run-script start"
}
Expand Down
6 changes: 2 additions & 4 deletions amplify/backend/api/unirent/cli-inputs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
"apiName": "unirent",
"serviceName": "AppSync",
"defaultAuthType": {
"mode": "API_KEY",
"expirationTime": 365,
"apiKeyExpirationDate": "2025-07-31T15:44:56.006Z",
"keyDescription": "unirent-api-key"
"mode": "AMAZON_COGNITO_USER_POOLS",
"cognitoUserPoolId": "authunirenta9aa32e0"
},
"additionalAuthTypes": [
{
Expand Down
9 changes: 7 additions & 2 deletions amplify/backend/api/unirent/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"AppSyncApiName": "unirent",
"DynamoDBBillingMode": "PAY_PER_REQUEST",
"DynamoDBEnableServerSideEncryption": false,
"AuthModeLastUpdated": "2024-07-31T15:45:01.971Z",
"CreateAPIKey": 1
"AuthModeLastUpdated": "2024-09-22T18:56:19.405Z",
"AuthCognitoUserPoolId": {
"Fn::GetAtt": [
"authunirenta9aa32e0",
"Outputs.UserPoolId"
]
}
}
66 changes: 44 additions & 22 deletions amplify/backend/api/unirent/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
type SavedAccommodation @model @auth(rules: [{allow: public}]) {
type SavedAccommodation @model @auth(rules: [
{ allow: owner, operations: [create, read, update, delete] }, # User can manage their saved accommodations
{allow: private },
]) {
id: ID!
Accommodations: [Accommodation] @manyToMany(relationName: "SavedAccommodationAccommodation")
User: User @belongsTo
}

type ChatRoom @model @auth(rules: [{allow: public}]) {
id: ID!
Users: [User] @manyToMany(relationName: "UserChatRoom")
Messages: [Message] @hasMany(indexName: "byChatRoom", fields: ["id"])
LastMessage: Message @hasOne
Accommodation: Accommodation @hasOne
}

type Message @model @auth(rules: [{allow: public}]) {
id: ID!
createdAt: AWSDateTime!
text: String!
chatRoomId: ID! @index(name: "byChatRoom")
userId: ID! @index(name: "byUser")
}

enum PropertyEnum {
HDB
CONDO
LANDED
UNIVERSITY
}

type Accommodation @model @auth(rules: [{allow: public}]) {
type Accommodation @model @auth(rules: [
# allow all authenticated users ability to create accommodation
# allow owners ability to update and delete their accommodation
{ allow: owner }
# allow all authenticated users to read accommodation
{ allow: private, operations: [read] }
]) {
id: ID!
availableDate: AWSDate
description: String!
images: [String!]
images: [String]!
price: Int!
propertyType: PropertyEnum
propertyType: PropertyEnum!
rented: Boolean
createdAt: AWSDateTime!
title: String!
address: AWSJSON
# For encryption purpose
address: AWSJSON!
# address: String!
userId: ID! @index(name: "byUser")
unitFeature: [String]
# For encryption purpose
latitude: Float
longitude: Float
# latitude: String
# longitude: String
savedaccommodations: [SavedAccommodation] @manyToMany(relationName: "SavedAccommodationAccommodation")
User: User @belongsTo(fields: ["userId"])
}

type User @model @auth(rules: [{allow: public}]) {
type User @model @auth(rules: [
{ allow: owner, operations: [read, update, create] }, # only user owner can manage
{ allow: private, operations: [read] }, # only user owner can manage
]) {
id: ID!
name: String!
status: String
Expand All @@ -55,3 +57,23 @@ type User @model @auth(rules: [{allow: public}]) {
Messages: [Message] @hasMany(indexName: "byUser", fields: ["id"])
SavedAccommodation: SavedAccommodation @hasOne
}

type Message @model @auth(rules: [
{ allow: private},
]) {
id: ID!
createdAt: AWSDateTime!
text: String!
chatRoomId: ID! @index(name: "byChatRoom", sortKeyFields: ["createdAt"], queryField: "listMessagesByChatRoom")
userId: ID! @index(name: "byUser")
}

type ChatRoom @model @auth(rules: [
{ allow: private},
]) {
id: ID!
Users: [User] @manyToMany(relationName: "UserChatRoom")
Messages: [Message] @hasMany(indexName: "byChatRoom", fields: ["id"])
LastMessage: Message @hasOne
Accommodation: Accommodation @hasOne
}
41 changes: 34 additions & 7 deletions amplify/backend/backend-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,15 @@
"service": "API Gateway"
},
"unirent": {
"dependsOn": [],
"dependsOn": [
{
"attributes": [
"UserPoolId"
],
"category": "auth",
"resourceName": "unirenta9aa32e0"
}
],
"output": {
"authConfig": {
"additionalAuthenticationProviders": [
Expand All @@ -60,12 +68,10 @@
}
],
"defaultAuthentication": {
"apiKeyConfig": {
"apiKeyExpirationDate": "2025-07-31T15:44:56.006Z",
"apiKeyExpirationDays": 365,
"description": "unirent-api-key"
},
"authenticationType": "API_KEY"
"authenticationType": "AMAZON_COGNITO_USER_POOLS",
"userPoolConfig": {
"userPoolId": "authunirenta9aa32e0"
}
}
}
},
Expand Down Expand Up @@ -105,6 +111,11 @@
"providerPlugin": "awscloudformation",
"service": "Lambda"
},
"generateEncryptionKeyAPI": {
"build": true,
"providerPlugin": "awscloudformation",
"service": "Lambda"
},
"geocodingHandler": {
"build": true,
"providerPlugin": "awscloudformation",
Expand Down Expand Up @@ -138,6 +149,22 @@
}
]
},
"AMPLIFY_function_generateEncryptionKeyAPI_deploymentBucketName": {
"usedBy": [
{
"category": "function",
"resourceName": "generateEncryptionKeyAPI"
}
]
},
"AMPLIFY_function_generateEncryptionKeyAPI_s3Key": {
"usedBy": [
{
"category": "function",
"resourceName": "generateEncryptionKeyAPI"
}
]
},
"AMPLIFY_function_geocodingHandler_deploymentBucketName": {
"usedBy": [
{
Expand Down
Loading

0 comments on commit 8380428

Please sign in to comment.