-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added OnCallUpdateModel that is used to handle the onCall entrypoint for all models
- Loading branch information
Showing
39 changed files
with
397 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 8 additions & 11 deletions
19
apps/demo-api/src/app/function/guestbook/guestbookentry.update.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
import { UpdateGuestbookEntryParams } from '@dereekb/demo-firebase'; | ||
import { inAuthContext } from '@dereekb/firebase-server'; | ||
import { onCallWithDemoNestContext } from '../function'; | ||
import { DemoUpdateModelfunction } from '../function'; | ||
import { guestbookEntryForUser } from './guestbook.util'; | ||
|
||
export const updateGuestbookEntry = onCallWithDemoNestContext( | ||
inAuthContext(async (nest, data: UpdateGuestbookEntryParams, context) => { | ||
const guestbookEntryUpdateEntry = await nest.guestbookActions.updateGuestbookEntry(data); | ||
export const updateGuestbookEntry: DemoUpdateModelfunction<UpdateGuestbookEntryParams> = async (nest, data, context) => { | ||
const guestbookEntryUpdateEntry = await nest.guestbookActions.updateGuestbookEntry(data); | ||
|
||
const uid = context.auth.uid; | ||
const { guestbook: guestbookId } = guestbookEntryUpdateEntry.params; | ||
const uid = context.auth.uid; | ||
const { guestbook: guestbookId } = guestbookEntryUpdateEntry.params; | ||
|
||
const guestbookEntryDocument = guestbookEntryForUser(nest, guestbookId, uid); | ||
await guestbookEntryUpdateEntry(guestbookEntryDocument); | ||
}) | ||
); | ||
const guestbookEntryDocument = guestbookEntryForUser(nest, guestbookId, uid); | ||
await guestbookEntryUpdateEntry(guestbookEntryDocument); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './update.function'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { updateProfile } from './../profile/profile.update'; | ||
import { updateGuestbookEntry } from './../guestbook/guestbookentry.update'; | ||
import { inAuthContext, onCallUpdateModel } from '@dereekb/firebase-server'; | ||
import { DemoOnCallUpdateModelMap, onCallWithDemoNestContext } from '../function'; | ||
|
||
export const demoUpdateModelMap: DemoOnCallUpdateModelMap = { | ||
guestbookEntry: updateGuestbookEntry, | ||
profile: updateProfile | ||
}; | ||
|
||
export const demoUpdateModel = onCallWithDemoNestContext(inAuthContext(onCallUpdateModel(demoUpdateModelMap))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
import { ProfileDocument, UpdateProfileParams } from '@dereekb/demo-firebase'; | ||
import { inAuthContext } from '@dereekb/firebase-server'; | ||
import { onCallWithDemoNestContext } from '../function'; | ||
import { DemoUpdateModelfunction } from '../function'; | ||
import { profileForUser } from './profile.util'; | ||
|
||
export const updateProfile = onCallWithDemoNestContext( | ||
inAuthContext(async (nest, data: UpdateProfileParams, context) => { | ||
const updateProfile = await nest.profileActions.updateProfile(data); | ||
export const updateProfile: DemoUpdateModelfunction<UpdateProfileParams> = async (nest, data, context) => { | ||
const updateProfile = await nest.profileActions.updateProfile(data); | ||
|
||
const uid = updateProfile.params.uid ?? context.auth.uid; | ||
const profileDocument: ProfileDocument = profileForUser(nest, uid); | ||
const uid = updateProfile.params.uid ?? context.auth.uid; | ||
const profileDocument: ProfileDocument = profileForUser(nest, uid); | ||
|
||
await updateProfile(profileDocument); | ||
}) | ||
); | ||
await updateProfile(profileDocument); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.