-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rebase/20240720 #19
Merged
Merged
Rebase/20240720 #19
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
dba8c33
ar preg nothing
angeloreale 48070f7
ar preg nothing
angeloreale e9a90ef
ar preg nothing
angeloreale 119691a
ar(fix) migration noise
angeloreale 18ef945
ar(fix) migration noise
angeloreale 0f5676a
Merge branch 'dev' into rebase/20240720
angeloreale e9fa194
ar(fix) migration noise
angeloreale 65adced
ar(fix) migration noise
angeloreale 57babc1
ar(fix) migration noise
angeloreale 7e16f64
ar(fix) migration noise
angeloreale 6e49d5c
ar(fix) migration noise
angeloreale 7f6c5bd
ar(fix) migration noise
angeloreale 1b07fd1
ar(fix) migration noise
angeloreale 4ae78fc
ar(fix) migration noise
angeloreale 8e631b2
ar(fix) migration noise
angeloreale 0b052e8
ar(fix) migration noise
angeloreale 6a19540
ar(fix) migration noise
angeloreale 4e30da2
ar(fix) migration noise
angeloreale f221f10
ar(fix) migration noise
angeloreale 9dd126a
ar(fix) migration noise
angeloreale 1d2842c
ar(fix) migration noise
angeloreale 24205a6
ar(fix) migration noise
angeloreale 80ca1ec
ar(fix) migration noise
angeloreale 79330d9
ar(fix) migration noise
angeloreale 1c2c64f
ar(fix) migration noise
angeloreale f19db75
ar(fix) migration noise
angeloreale a8496c6
ar(fix) migration noise
angeloreale d97573e
ar(fix) migration noise
angeloreale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,33 @@ | ||
/* eslint @typescript-eslint/consistent-type-assertions:0 */ | ||
// rm-decorator.ts input: rm meta; output: decorated rm meta; | ||
'use server'; | ||
import type { IDCharacter, INCharacter } from '@types'; | ||
import type { ICard } from '@dreampipcom/oneiros'; | ||
import type { INCharacter } from '@types'; | ||
|
||
/* private */ | ||
const decorateCharacter = (character: INCharacter, uMeta: any): IDCharacter => { | ||
const decd: IDCharacter = { ...character }; | ||
decd.favorite = undefined; | ||
if (uMeta?.rickmorty?.favorites?.characters?.includes(character?.id)) decd.favorite = true; | ||
else decd.favorite = false; | ||
const decorateCharacter = (character: INCharacter, uMeta: any): ICard => { | ||
const decd: ICard = { | ||
id: `list__char--${character?.name}`, | ||
className: '', | ||
// onLike: () => {}, | ||
title: `${character?.name}`, | ||
where: `${character?.location?.name}`, | ||
when: `${character?.status}`, | ||
image: `${character?.image}`, | ||
price: '299€', | ||
link: 'https://www.dreampip.com', | ||
badgeLink: 'https://www.dreampip.com', | ||
rating: '3/5', | ||
selected: uMeta?.favorites?.includes(character.id), | ||
} as Record<string, any> as ICard; | ||
|
||
return decd; | ||
}; | ||
|
||
/* public */ | ||
export const decorateRMCharacters = async (characters: INCharacter[], uid: string): Promise<IDCharacter[]> => { | ||
export const decorateRMCharacters = async (characters: INCharacter[], uMeta: any): Promise<ICard[]> => { | ||
// const uMeta: UserSchema = await getUserMeta({ email: uid }); | ||
const decd: IDCharacter[] = characters.map((char) => decorateCharacter(char, { email: uid })); | ||
const decd: ICard[] = characters.map((char) => decorateCharacter(char, uMeta)); | ||
console.log({ characters, uMeta, decd }); | ||
return decd; | ||
}; |
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
55 changes: 55 additions & 0 deletions
55
lib/model/interfaces/services/hypnos/private/hypnos-private-user-connector.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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// hypnos-private-user-like-listing.ts | ||
// rm-connector.ts | ||
// to-do: use prisma for graph type | ||
import type { ICard } from '@dreampipcom/oneiros'; | ||
|
||
import { cookies } from 'next/headers'; | ||
// const CHARS = ` | ||
// query { | ||
// characters() { | ||
// info { | ||
// count | ||
// } | ||
// results { | ||
// id | ||
// name | ||
// status | ||
// origin { | ||
// name | ||
// } | ||
// location { | ||
// name | ||
// } | ||
// image | ||
// } | ||
// } | ||
// } | ||
// `; | ||
|
||
async function fetchREPL({ paramsStr, method, listings }: any) { | ||
// to-do: might be worth hardcoding the api in case too many middleware requests are billed | ||
try { | ||
const cookieStore = cookies(); | ||
const cookieString = cookieStore.toString(); | ||
const payload = JSON.stringify({ listings }); | ||
const req = await fetch(`${process.env.API_HOST}/api/v1/user${paramsStr}`, { | ||
method, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
cookies: cookieString, | ||
}, | ||
body: payload, | ||
credentials: 'include', | ||
}); | ||
const json = await req.json(); | ||
return json; | ||
} catch (e) { | ||
return { ok: false, status: 500, message: JSON.stringify(e), data: [] }; | ||
} | ||
} | ||
|
||
export const updateUserFavoriteListings: ({ paramsStr }: any) => Promise<ICard[]> = async ({ listings }) => { | ||
const entries = await fetchREPL({ paramsStr: '', method: 'PATCH', listings }); | ||
const response = entries?.data; | ||
return response; | ||
}; |
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,2 @@ | ||
// index.ts | ||
export { updateUserFavoriteListings } from './hypnos-private-user-connector'; |
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,10 +1,12 @@ | ||
// index.ts | ||
import * as rickmorty from './rickmorty'; | ||
import * as hypnosPublic from './hypnos/public'; | ||
import * as hypnosPrivate from './hypnos/private'; | ||
|
||
const services = { | ||
rickmorty, | ||
hypnosPublic, | ||
hypnosPrivate, | ||
}; | ||
|
||
export default services; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit