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

나무 1주차 #32

Merged
merged 8 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 105 additions & 69 deletions packages/namu/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 50 additions & 38 deletions packages/namu/login.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 0 additions & 54 deletions packages/namu/src/api/index.js

This file was deleted.

5 changes: 5 additions & 0 deletions packages/namu/src/constant/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const METHOD = {
GET: "GET",
POST: "POST",
DELETE: "DELETE",
};
4 changes: 4 additions & 0 deletions packages/namu/src/constant/url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const BASE_SERVER_URL = "http://localhost:3000";
export const BASE_CLIENT_URL = "http://localhost:5510";

export const FOX_URL = "https://randomfox.ca";
26 changes: 26 additions & 0 deletions packages/namu/src/helper/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { METHOD } from "../constant/api";

export async function postAsync(url: string, data: object) {
return getParsedData(url, getConfig(METHOD.POST, data));
}

export async function getAsync(url: string, data: object) {
return getParsedData(url, getConfig(METHOD.GET, data));
}

export async function deleteAsync(url: string, data: object) {
Copy link
Contributor

Choose a reason for hiding this comment

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

await 키워드가 없는 함수에 async 가 붙어있네용?. ?

Copy link
Member Author

Choose a reason for hiding this comment

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

핚 이런 날카로운 리뷰..^^ my (옛)pair답군요 감사합니당!!

return getParsedData(url, getConfig(METHOD.DELETE, data));
}

function getConfig(method: string, data: object) {
return {
method: method,
headers: new Headers({ "content-type": "application/json" }),
body: data && JSON.stringify(data),
Comment on lines +18 to +19
Copy link
Member

Choose a reason for hiding this comment

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

&& 연산자로 초기화한 부분👍👍

};
}

async function getParsedData(url: string, config: object) {
const response = await fetch(url, config);
return await response.json();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

오 parsed 부분와 config 를 이렇게 나누면 나중에 재활용하거나 활용하기 좋아 보이네용 굳굳 👍🏻

4 changes: 2 additions & 2 deletions packages/namu/src/helper/debounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function throttle(delay, noTrailing, callback, debounceMode) {
cancelled = true;
}

if (typeof noTrailing !== 'boolean') {
if (typeof noTrailing !== "boolean") {
debounceMode = callback;
callback = noTrailing;
noTrailing = undefined;
Expand Down Expand Up @@ -44,7 +44,7 @@ function throttle(delay, noTrailing, callback, debounceMode) {
} else if (noTrailing !== true) {
timeoutID = setTimeout(
debounceMode ? clear : exec,
debounceMode === undefined ? delay - elapsed : delay,
debounceMode === undefined ? delay - elapsed : delay
);
}
}
Expand Down
5 changes: 0 additions & 5 deletions packages/namu/src/helper/dom.js

This file was deleted.

Loading