- creating a folder named database and writing a function to connect a db.
- creating a new folder named models.
- create a file named user.js then create a schema and then model and export it.
- in app folder create a api folder in it register folder in it a route.js file
- create a asynce function call inside db connection
- destructure name, email, password from req
- validate schema with joi
- passsing the dynamic property from the next js. you can checkout the docs for it.
- validate schema
- check user exist and creating user by hashing password.
- create a services folder inside it register folder inside it a index.js file
- here call the api route.
- creating route api for login
- create login service file
- sending the form data and calling the api from page of login folder
- set context authUser and userDetail and use these in the login page and we will storing the token in the cookies and user info in the localstorage
- in context use useEffect and fetch the data from the cookie and localstorage.
- create model schema, then create api route, then create services file.
-
create firebase new project and then it will give you the firebase sdk.
-
from sdk you can copy firebaseConfig and paste it in the utils index.js
-
from sdk copy intializeApp and paste it in the admin-view > add-proucts > page.js and import initializeApp
-
In firebase :- go to console > Build > storage > get started > start in test mode > copy the link.
-
go the utils index.js and store it variable and export it.
-
in page.js make variable name storage and use getStorage function from firebase and pass it the storageURl
note: when we making the get request then we need to give absolute url "api/dummy" is not working we need to give full url in case of get request.