-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add list #51
base: main
Are you sure you want to change the base?
Conversation
… table with a dummy shopping list
.env
Outdated
@@ -0,0 +1,13 @@ | |||
# Environment variables declared in this file are automatically made available to Prisma. |
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.
don't commit this file
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.
git rm --cached name_of_file
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.
fixed
package.json
Outdated
"eslint": "8.34.0", | ||
"eslint-config-next": "13.1.6", | ||
"fastify": "^4.13.0", |
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.
why is fastify installed here? Don't we use next api endpoints?
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.
removed
package.json
Outdated
"eslint": "8.34.0", | ||
"eslint-config-next": "13.1.6", | ||
"fastify": "^4.13.0", | ||
"fastify-zod": "^1.2.0", |
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.
please also remove this
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.
removed
src/pages/api/addList.ts
Outdated
|
||
response.status(200).json({ message: "List added successfully" }); | ||
} else { | ||
response.status(405).json({ message: "Method not allowed" }); |
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.
if you're already adding error handling, why not try catch the prisma client and handle Zod validation errors?
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.
changed with 'try' and working by testing with htt page, new list message 200 is there and appearing on prisma studio.
src/pages/api/test.ts
Outdated
response: NextApiResponse | ||
) { | ||
if (request.method == "GET") { | ||
const list = await prisma.list.findMany({}); |
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.
same here, see above comment
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.
removed as it was just a test page
tsconfig.json
Outdated
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"module": "commonjs", |
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.
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.
fixed
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.
see changes and reverse merge before submitting a PR
prisma/schema.prisma
Outdated
model Items { | ||
id String @id @default(uuid()) | ||
name String | ||
Linked_to_List List? @relation(fields: [ListID], references: [id]) |
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.
@n1lsw please see Dans comments in discord about naming conventions here and address that in a fix-PR, then merge those changes into this PR from main, once the fix-PR has been merged.
Thanks!
src/pages/api/addItem.ts
Outdated
create: { | ||
name: inputList, | ||
}, | ||
update: {}, |
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.
why is update empty? Looks like you don't need an upsert here, more like an insert()
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.
edit: I meant create(), insert() doesn't exist as a valid prisma method.
If you want to update if there is already an item present, you need to fill this update object
src/pages/api/addItem.ts
Outdated
name: "other", | ||
}, | ||
data: { | ||
Items: { |
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.
please update with new naming conventions after finishing above comment
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.
see comments, remember to reverse merge
I didn't find this script in main and unfortunately had to write an own one :( |
No description provided.