Skip to content
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

Frontend integration #25

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

AlexanderSUS
Copy link

@AlexanderSUS AlexanderSUS commented Aug 19, 2024

  1. Integrate server with frontend https://github.com/rolling-scopes-school/nodejs-aws-shop-react :
  • align server responses with frontend requests
  • recover basic authorization
  • add register endpoint which create a user
  • add login endpoint which returns access_token (Basic auth). So after user created, backend accept token from task Taks 7 if the same credentials was used.
  1. Add bash script to get access_token in one command
  2. Fix eslint and lint code
  3. Update README.md

For proper work of orders endpoint you need also merge this PR rolling-scopes-school/nodejs-aws-shop-react#140

P.S.
I don't know what was initial logic of application. So I didn't touch commented code and other stuff that application currently do not use.

Copy link
Member

@apalchys apalchys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my comments mostly minor. great job

env.example Outdated

APP_URL=http://localhost:4000

GITHUB_ACCOUNT_LOGIN=yourGithubLogin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to name AUTH_USERNAME and add a comment, it should be your GitHub username.

I also suggest to group APP_URL, AUTH_USERNAME and AUTH_PASSWORD together with a comment, they are needed to make the script work.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

function encodeUserToken(user) {
const { id, name, password } = user;
function encodeUserToken(user: User) {
const { /*id,*/ name, password } = user;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { /*id,*/ name, password } = user;
const { name, password } = user;

lets remove

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -1,39 +1,50 @@
import { Injectable } from '@nestjs/common';
import { v4 } from 'uuid';

import { randomUUID } from 'crypto';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { randomUUID } from 'crypto';
import { randomUUID } from 'node:crypto';

minor but I find it's more convenient and readable to prefix node imports with node:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

id,
id: randomUUID(),
user_id,
created_at: getDate(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder, why do you need to store date as string and just actual timestamp (Date.now()) ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I forgot update that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants