mhr
@rmh03130151
Reviews Written
18
Average Rating
4.5
Posts
Q&A
typeorm migration ์คํ์ด ์ ๋ฉ๋๋ค.
์ ๋ก์ด๋ ์๋ ํ์ธ์. ์๋ ค์ฃผ์ ๋ฐฉ์๋๋ก ์คํํด๋ Missing required argument: dataSource ์๋ฌ๊ฐ ๋ฐ์ํฉ๋๋ค. ์ง์ ๋ง์ด๊ทธ๋ ์ด์ ํ์ผ์ ์์ฑํ ๋ค npm run db:migrate๋ฅผ ์คํ์์ผ๋ ๋ง์ฐฌ๊ฐ์ง์ด๊ณ ์. datasource๊ฐ db connectio ๊ด๋ฆฌํ๋ ๊ฐ์ฒด๋ฅผ ์ด์ผ๊ธฐํ๊ณ , typeorm ๋ฌธ์์ ๋์ค๋ DataSource ๊ฐ์ฒด ์์ฑ ๋ถ๋ถ์ Nest์์ ๊ด๋ฆฌํ๋ ๊ฒ ๊ฐ์ต๋๋ค. TypeOrmModule.footRootAsync ํจ์์ ์ต์ ์ค์ dataSourceFactory๋ผ๋ ๊ฒ ์์ด์ dataSourceFactory: async () => { return new DataSource({ type: 'mysql', host: 'localhost', port: 3306, username: process.env.DB_USERNAME, password: process.env.DB_PASSWORD, database: process.env.DB_DATABASE, entities: [ ChannelChats, ChannelMembers, Channels, DMs, Mentions, Users, WorkspaceMembers, Workspaces, ], migrations: [__dirname + '/src/migrations/*.ts'], charset: 'utf8mb4', synchronize: false, logging: true, });}, ์์ฒ๋ผ ์๋ํด๋ดค๋๋ฐ ํจ๊ณผ๋ ์๋ค์.
- 0
- 4
- 2.3K
Q&A
typeorm migration ์คํ์ด ์ ๋ฉ๋๋ค.
์ ์์ฒญ ๋น ๋ฅธ ๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค. ์ ๊ทธ๋ผ ํน์ package.json์๋ ๋ณ๊ฒฝ์ฌํญ์ ์ด๋ค ์์ผ๋ก ๋ฐ์ํด์ผํ ๊น์? { ... "db:create-migration": "npm run typeorm migration:create -- -n", "db:generate-migration": "npm run typeorm migration:generate -- -n" } ๊ฐ์์์๋ ์์ฒ๋ผ ์ค์ ๋์ด ์๋๋ฐ, -n์ด ์์ด์ก๋ค๊ณ ํด์ ์์ ๊ณ ๋๋ ค๋ณด๋ dataSource๊ฐ ํ์ํ๋ค๊ณ ํด์ entities ํด๋๋ฅผ ์ง์ ํด์ npm run db:generate-migration src/migrations/categoryToType -d src/entities ์ด๋ ๊ฒ ํด๋ดค๋๋ฐ ๊ฒฐ๊ณผ๊ฐ ์ ๋์ค๋ค์. ๊ฒ์ํด๋ณด๋๊น dataSource๋ผ๋ ๊ฒ https://typeorm.biunav.com/en/data-source.html#what-is-datasource ์ฌ๊ธฐ ๋์จ ๊ฒ์ฒ๋ผ DB connection์ ๋ด๋นํ๋ ๋ถ๋ถ์ธ ๊ฒ ๊ฐ์๋ฐ, ์ฌ๊ธฐ์๋ ์ด๋ค ์์ผ๋ก ์ง์ ์ ํด์ค์ผํ ๊น์.
- 0
- 4
- 2.3K
Q&A
typeorm migration ์คํ์ด ์ ๋ฉ๋๋ค.
์ง๋ฌธ ์ฌ๋ฆฌ๊ณ ๊ตฌ๊ธ๋งํ๋ค๊ฐ ์ฐพ์์ต๋๋ค. https://stackoverflow.com/questions/72682474/typeorm-migrationgenerate-failure-not-enough-non-option-arguments-got-0-need ํน์ ๋์์ด ๋์๋ ๋ถ๋ค์ด ์์๊น ์ถ์ด์ ์ง๋ฌธ๊ธ์ ๊ทธ๋ฅ ๋จ๊ฒจ๋๊ฒ ์ต๋๋ค. typeorm์ด ์ ๋ฐ์ดํธ๋๋ฉด์ ๋ณํ๊ฐ ์ข ์์๋ค์.
- 0
- 4
- 2.3K
Q&A
axios์ get request๋ฅผ ์ด์ฉํด์ products๋ฅผ ๊ฐ์ ธ์ค๋ ๋ถ๋ถ์์ 500 ์๋ฌ๊ฐ ๋ฉ๋๋ค.
์๋ ํ์ธ์. ๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค. ํ์ฌ ์๋์์ Webstorm์ ์ฌ์ฉํ๊ณ ์๋๋ฐ์. ํฌํธ๋ฅผ 4000๋ฒ์ผ๋ก ๋ฐ๊ฟ๋ ๋ง์ฐฌ๊ฐ์ง๋ค์. ์๋ฒ ํฌํธ๋ฅผ ๋ฐ๊พธ์ด๋ orderType์ด products์ธ ๊ฒฝ์ฐ์ ํ ์คํธ๋ ํต๊ณผํ์ง๋ง ์๋ฌ๋ ๋ฐ์ํ๋ฉด์ ์๋ฌ ๋ก๊ทธ์์ response์ data๋ undefined๋ก ๋์ด์์ต๋๋ค. ๋ญ๊ฐ ๋ฌธ์ ์ง ๊ฐ์ด ์ ์กํ์ง ์์์ axios์ msw๋ฅผ ์ง์ฐ๊ณ ๊ฐ์ ์ฝ๋์ ๊ฐ์ ๋ฒ์ ์ผ๋ก ๋ค์ ์ค์นํด๋ดค๋๋ฐ ๊ทธ๋๋ ๋ง์ฐฌ๊ฐ์ง๋ค์. ์๋ฌ ๋ฉ์์ง๊ฐ ์๋์ ๊ฐ์๋ฐ ํน์ ๋์์ด ๋ ์ง ๋ชฐ๋ผ ๊ณต์ ํฉ๋๋ค. ๊ฐ์ฌํฉ๋๋ค. PASS src/pages/OrderPage/tests/Type.test.js โ Console console.group orderType: products at loadItems (src/pages/OrderPage/Type.js:30:15) console.error Error: Request failed with status code 500 at createError (C:\Users\mhr\Desktop\web\inflearn_react_testing\react-shop-test\node_modules\axios\lib\core\createError.js:16:15) at settle (C:\Users\mhr\Desktop\web\inflearn_react_testing\react-shop-test\node_modules\axios\lib\core\settle.js:17:12) at XMLHttpRequestOverride.onloadend (C:\Users\mhr\Desktop\web\inflearn_react_testing\react-shop-test\node_modules\axios\lib\adapters\xhr.js:54:7) at XMLHttpRequestOverride.trigger (C:\Users\mhr\Desktop\web\inflearn_react_testing\react-shop-test\node_modules\@mswjs\interceptors\src\interceptors\XMLHttpRequest\XMLHttpRequestOverride.ts:168:17) at C:\Users\mhr\Desktop\web\inflearn_react_testing\react-shop-test\node_modules\@mswjs\interceptors\src\interceptors\XMLHttpRequest\XMLHttpRequestOverride.ts:323:18 { config: { url: 'http://localhost:5000/products', method: 'get', headers: { Accept: 'application/json, text/plain, */*' }, transformRequest: [ [Function: transformRequest] ], transformResponse: [ [Function: transformResponse] ], timeout: 0, adapter: [Function: xhrAdapter], xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, validateStatus: [Function: validateStatus], transitional: { silentJSONParsing: true, forcedJSONParsing: true, clarifyTimeoutError: false }, data: undefined }, request: XMLHttpRequestOverride { _events: [], UNSENT: 0, OPENED: 1, HEADERS_RECEIVED: 2, LOADING: 3, DONE: 4, onreadystatechange: null, onabort: [Function: handleAbort], onerror: [Function: handleError], onload: null, onloadend: [Function: onloadend], onloadstart: null, onprogress: null, ontimeout: [Function: handleTimeout], url: 'http://localhost:5000/products', method: 'GET', readyState: 4, withCredentials: false, status: 500, statusText: 'Internal Server Error', data: '', response: '', responseType: 'text', responseText: '', responseXML: null, responseURL: '', upload: null, timeout: 0, _requestHeaders: HeadersPolyfill { _headers: [Object], _names: [Map] }, _responseHeaders: HeadersPolyfill { _headers: [Object], _names: [Map] }, async: true, user: undefined, password: undefined }, response: { data: '', status: 500, statusText: 'Internal Server Error', headers: { 'x-powered-by': 'msw' }, config: { url: 'http://localhost:5000/products', method: 'get', headers: [Object], transformRequest: [Array], transformResponse: [Array], timeout: 0, adapter: [Function: xhrAdapter], xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, validateStatus: [Function: validateStatus], transitional: [Object], data: undefined }, request: XMLHttpRequestOverride { _events: [], UNSENT: 0, OPENED: 1, HEADERS_RECEIVED: 2, LOADING: 3, DONE: 4, onreadystatechange: null, onabort: [Function: handleAbort], onerror: [Function: handleError], onload: null, onloadend: [Function: onloadend], onloadstart: null, onprogress: null, ontimeout: [Function: handleTimeout], url: 'http://localhost:5000/products', method: 'GET', readyState: 4, withCredentials: false, status: 500, statusText: 'Internal Server Error', data: '', response: '', responseType: 'text', responseText: '', responseXML: null, responseURL: '', upload: null, timeout: 0, _requestHeaders: [HeadersPolyfill], _responseHeaders: [HeadersPolyfill], async: true, user: undefined, password: undefined } }, isAxiosError: true, toJSON: [Function: toJSON] }
- 0
- 2
- 1K
Q&A
์ ์๋, ์ง๋ฌธ์ด ์์ต๋๋ค.
์ ๋ ์ด๋ถ๋ถ์ด ์ ๊น ํท๊ฐ๋ ธ๋๋ฐ, ๋จธ์ ๋ฌ๋ ํ๋ก๊ทธ๋จ์ ์ผ์ข ์ ์ํ์ ์ธ ํจ์๋ผ๊ณ ์๊ฐํ๋ ํท๊ฐ๋ฆฌ์ง ์๊ฒ ๋์์ต๋๋ค. ์ด๋ค x๊ฐ์ ์ฃผ์์ ๋ ์ด์ ๋ฐ๋ฅธ ์ด์ ๋์ํ๋ ํ๋์ y๊ฐ์ ๋ฐํํ๋ ๊ฒ์ ํจ์๋ผ๊ณ ํ์์์. ๋จธ์ ๋ฌ๋์์ ์ด x๊ฐ์ ํด๋นํ๋ ๊ฒ์ด feature๋ค์ด๊ณ , y๊ฐ์ ํด๋นํ๋ ๊ฒ์ด target์ธ ์ ์ธ๋ฐ, training data set๊ณผ test data set์ ๋๋ ๋์๋ ์ด ๋ณธ์ง์ ์ธ ์๋ฏธ ์๋์์ ๊ฐ๊ฐ์ training / test๋ก ๋๋๋ ๊ฒ์ด๋ feature์ธ X๋ฅผ train, test๋ก ๋๋ ๊ฒ์ด ์ค๊ณ , target์ธ y๋ฅผ train, test๋ก ๋๋ ๊ฒ์ด ์ค๊ฒ ๋๋ ๊ฒ์ผ๋ก ์ดํดํ์ต๋๋ค. ์จ๋๊ณ ๋๋ ๋๋ฌด ๋น์ฐํ ์๋ฆฌ ๊ฐ๊ธฐ๋ ํ๋ฐ ๋๊ตฐ๊ฐ์๊ฒ๋ ๋์์ด ๋๊ธธ ๋ฐ๋๋๋ค.
- 0
- 3
- 241
Q&A
์ค์ฒฉ๋ router ์ด์ฉ์ ๊ฐ๊ฐ์ ํ์ด์ง๋ url๋ง์ผ๋ก๋ ์ ์์ ์ธ ์ ๊ทผ์ด ๊ฐ๋ฅํด์ผํ ๊น์?
์ ์ ๊ทธ๋ฆฌ๊ณ ์ ํฌ๋ธ ์ฑ๋์ Nest.js ๊ฐ์ข ์์์ด ๋ ๊ฐ๊ฐ ์ฌ๋ผ์์๋๋ฐ, ํน์ ์ธ์ ๊ฐ์ข๊ฐ ์ฌ๋ผ์ฌ์ง ์ ์ ์์๊น์?
- 0
- 2
- 256
Q&A
๋น๋๊ธฐ ์์ ์ด ์์ ๊ฒฝ์ฐ useReducer์ redux์ dispatch ํจ์์ ์คํ์ผ๋ก ์ธํ state ๋ณ๊ฒฝ ์์๊ฐ ๋ณด์ฅ์ด ์๋๋์?
๊ฐ์ฌํฉ๋๋ค. ํฐ ๋์ ๋์์ต๋๋ค!
- 0
- 2
- 675
Q&A
useReducer ์ฌ์ฉ์ dispatch ํจ์์ generic์ผ๋ก action ํ์ ์ ๋๊ฒจ์ค ๋ ์๋ฌ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ ๋ก์ด๋ ์๋ ํ์ธ์. ๋น ๋ฅธ ๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค. function useReducerR extends ReducerWithoutActionany>, I>( reducer: R, initializerArg: I, initializer: (arg: I) => ReducerStateWithoutActionR>): [ReducerStateWithoutActionR>, DispatchWithoutAction];/** * An alternative to `useState`. * * `useReducer` is usually preferable to `useState` when you have complex state logic that involves * multiple sub-values. It also lets you optimize performance for components that trigger deep * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usereducer */// overload where dispatch could accept 0 arguments.function useReducerR extends ReducerWithoutActionany>>( reducer: R, initializerArg: ReducerStateWithoutActionR>, initializer?: undefined): [ReducerStateWithoutActionR>, DispatchWithoutAction];/** * An alternative to `useState`. * * `useReducer` is usually preferable to `useState` when you have complex state logic that involves * multiple sub-values. It also lets you optimize performance for components that trigger deep * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usereducer */// overload where "I" may be a subset of ReducerState; used to provide autocompletion.// If "I" matches ReducerState exactly then the last overload will allow initializer to be omitted.// the last overload effectively behaves as if the identity function (x => x) is the initializer.function useReducerR extends Reducerany, any>, I>( reducer: R, initializerArg: I & ReducerStateR>, initializer: (arg: I & ReducerStateR>) => ReducerStateR>): [ReducerStateR>, DispatchR>>];/** * An alternative to `useState`. * * `useReducer` is usually preferable to `useState` when you have complex state logic that involves * multiple sub-values. It also lets you optimize performance for components that trigger deep * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usereducer */// overload for free "I"; all goes as long as initializer converts it into "ReducerState".function useReducerR extends Reducerany, any>, I>( reducer: R, initializerArg: I, initializer: (arg: I) => ReducerStateR>): [ReducerStateR>, DispatchR>>];/** * An alternative to `useState`. * * `useReducer` is usually preferable to `useState` when you have complex state logic that involves * multiple sub-values. It also lets you optimize performance for components that trigger deep * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usereducer */// I'm not sure if I keep this 2-ary or if I make it (2,3)-ary; it's currently (2,3)-ary.// The Flow types do have an overload for 3-ary invocation with undefined initializer.// NOTE: without the ReducerState indirection, TypeScript would reduce S to be the most common// supertype between the reducer's return type and the initialState (or the initializer's return type),// which would prevent autocompletion from ever working.// TODO: double-check if this weird overload logic is necessary. It is possible it's either a bug// in older versions, or a regression in newer versions of the typescript completion service.function useReducerR extends Reducerany, any>>( reducer: R, initialState: ReducerStateR>, initializer?: undefined): [ReducerStateR>, DispatchR>>]; ์์ ํ์ผ์ด ์ ๊ฐ ํ์ฌ ์ฌ์ฉํ๊ณ ์๋ ๋ฒ์ ์ useReducer๊ฐ ์ ์๋์ด ์๋ react์ index.d.ts ํ์ผ์ธ๋ฐ์. ๋ฆฌํด๊ฐ๋ค์ ๋ณด์๋ฉด ์ฒซ ๋ฒ์งธ์ ๋ ๋ฒ์งธ ์ ์์ ๋ฆฌํด๊ฐ์ DispatchWithoutAction์ ๋ฆฌํดํ์ง๋ง, ๋๋จธ์ง 3, 4, 5๋ฒ์งธ์ ๋ฆฌํด๊ฐ์ dispatch ํจ์๋ Dispatch> ์ ๋๋ค. ์ด ๊ฒฝ์ฐ๋ action์ ๋ฐ์ ์ ์๋ ๊ฑฐ ์๋๊ฐ ์๊ฐํ๋๋ฐ์. ๋ฆฌ์กํธ ๋ ธ๋๋ฒ๋ ๊ฐ์ข ๋ค์ ๋ ์ ๋๋ฆ๋๋ก ํ์ดํํ ๋ dispatch ํจ์์ ์ ๋ค๋ฆญ์ ์คฌ๋ ๊ธฐ์ต์ด ๋์ ํ์ธํด๋ณด๋ useDispatch๋ react-redux์ index.d.ts ํ์ผ์ export function useDispatchTDispatch = Dispatchany>>(): TDispatch;export function useDispatchA extends Action = AnyAction>(): DispatchA>; ์ด๋ ๊ฒ ์ ์๋์ด ์๋๋ผ๊ณ ์. useDispatch์ Dispatch๋ ์์ useReducer์ Dispatch>์ด๋ ๋ง์ฐฌ๊ฐ์ง์ธ ๊ฒ ๊ฐ์์ ๊ทธ๋ ๊ฒ ์ฌ์ฉํ ์ ์์ง ์์๊น ์๊ฐํ์ต๋๋ค. ๊ทธ๋์ ์์ useReducer ํ์ ์ ์ ์ค์์ ๋ง์ง๋ง ๊ฒ์ ๋ง์ถฐ๋ณด๋ ค๊ณ useReducer์ generic์ ์ด๋์ ๋ ๋ค๋ฅด๊ฒ ์ค๋ด๋ ์ ์ ๋๋๋ผ๊ณ ์. ์ค๋ฒ๋ก๋ฉ ๊ฐ๋ฅํ ๊ฒ๋ค ์ค์์ ์๋ฑํ ๊ฒ์ ๊ฐ์ ธ์์ ์๋ฌ๊ฐ ๋๋ ๊ฒฝ์ฐ์๋ ํ์ ์ ๋ง์ถฐ๋ณด๋ผ๊ณ ๊ฐ์ ์ค์ ๋ง์ํ์ จ๋ ๊ฒ ๊ฐ์๋ฐ, ์ด ๊ฒฝ์ฐ๋ ์ด๋ป๊ฒ ํด๊ฒฐํ ์ ์์์ง ๊ถ๊ธํ๋ค์. ๊ฐ์ฌํฉ๋๋ค.
- 0
- 2
- 735
Q&A
eslint๋ฅผ ์ค์ ํ๊ณ ๋๋ ์จํต ๋นจ๊ฐ์ค์ด ๋จ๋๋ฐ ์ด๋ป๊ฒ ํด์ผ ํ๋์?
ํด๊ฒฐํ์ต๋๋ค. .eslintrc.js ์์ env ์์ node: true๋ฅผ ์ค์ ํด์ฃผ๋๊น module์ ๋ํด์ undefined ๋จ๋ ๊ฑด ์ฌ๋ผ์ก๊ณ , Delete `CR` eslint(prettier/prettier)๋ VS code์์ end of line ๊ธฐ๋ณธ ์ค์ ์ด LF๊ฐ ์๋๋ผ CRLF๋ก ์ค์ ๋์ด ์์ด์ ๋จ๋ ๊ฑฐ์๋ค์.
- 3
- 4
- 4.8K
Q&A
extendClass ํจ์ ๊ตฌํ์ IIFE๋ฅผ ์ฌ์ฉํ๋ ๊ฒ๊ณผ ๊ทธ๋ฅ ์ผ๋ฐ ํจ์๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ์ฐจ์ด๊ฐ ๋ฌด์์ธ์ง ๊ถ๊ธํฉ๋๋ค.
๊ฐ์ฌํฉ๋๋ค!
- 0
- 3
- 289




