-
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
TS migration #2
base: dev
Are you sure you want to change the base?
TS migration #2
Conversation
Mongoose to MongoDB Node.js Driver
src/app/api/user/route.ts
Outdated
|
||
const { name, email }: User = await req.json(); | ||
try { | ||
const db = client.db(); |
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.
db config should be made in the util file
src/app/error.tsx
Outdated
@@ -1,5 +1,7 @@ | |||
"use client"; | |||
|
|||
import React from "react"; |
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.
dont need react imports
src/app/layout.tsx
Outdated
@@ -1,6 +1,7 @@ | |||
/* eslint-disable new-cap */ | |||
import "./globals.css"; | |||
import { Inter } from "next/font/google"; | |||
import React from "react"; |
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.
dont need react imports
src/app/layout.tsx
Outdated
@@ -10,7 +11,11 @@ export const metadata = { | |||
description: "MongoDB Setup Integration with Next.js", | |||
}; | |||
|
|||
export default function RootLayout({ children }) { | |||
type Prop = { |
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.
use interface
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.
should be props
src/app/page.tsx
Outdated
e.preventDefault(); | ||
api({ | ||
method: "POST", | ||
url: "/api/user", | ||
body: { name, email }, | ||
}) | ||
.then(() => toast(`Submitted successfully!`)) | ||
.then((res) => { | ||
if (res.status >= 200 && res.status < 300) { |
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.
range checks dont work with http 😭 u can assume that if it goes thru its alr good
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.
oh i never wrote that, i think that was an issue with dev branch
src/utils/api.ts
Outdated
@@ -0,0 +1,25 @@ | |||
type apiGet = { |
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.
use interfaces
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.
should just be request or Request
src/utils/api.ts
Outdated
body: object; | ||
}; | ||
|
||
type apiResponse = { |
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.
should just be Response or response
had some issues with dev branch but should be good.