- this project is developing now.
- clone this repository.
npm installorpnpm install- create
.env.locallike.env.example - enter mongodb connect in
.env.local - if prisma can't db push you can try to change
.env.localto.env npx prisma generateto setup prismanpm run devorpnpm devto run server in dev mode
- Nextjs with Typescript
- Tailwindcss [css framework]
- prisma and mongodb [Database]
- firebase
- axios
- antd
- cookie
- js-cookie
- jsonwebtoken
-
create schema
-
authentication with jwt
-
users
- register
- login
- update profile with firebase
- delete account
-
links
- read link
- metatage og seo
- add link
- edit link info
- delete link
- read link
- rewrite authentication algorithm
- client send request to api with only access token.
- check access token when first load website.
-
create token with jwt
- access token '/api/auth/login'
- refresh token '/api/auth/refresh'
-
check auth on server side on
headerswithauthorization -
check auth on client side by
js-cookie -
after login token will response to client and setCookie with
js-cookie
Cookies.set("access_token", "theToken", {
path: "/",
expires: new Date(Date.now() * hours(1)),
});- when create cookie it need to input expires with Date()
- when want to add time use
hours(1)orminutes(10)and more at./components/lib/aboutTime.ts
- when sending api request it will check access token.
- if access token has expired, client must sending api request to '/api/auth/refresh'
- to get new access token and resend api request.
- get cookies on server side use
req.headers.authorization - get cookies on client side use
js-cookie
- api is in
backendfolder withexpressjs
- statusCode response description here
- [fixed] express can't handle data from
req.body. - It can not use
express.json()and app dont need to use express.json();