Skip to content

frontalnh/ddd-api-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Node DDD Component Generator

๋ณธ ํ”„๋กœ์ ํŠธ๋Š” Node.js ์„œ๋ฒ„๋ฅผ DDD ์•„ํ‚คํ…์ฒด๋กœ ์ƒ์„ฑํ•˜๋Š” ๊ฒฝ์šฐ ๊ธฐ๋ณธ CRUD ๋ฅผ ์œ„ํ•œ repository ๋ฐ router ๋ฅผ auto generate ํ•˜๊ธฐ ์œ„ํ•œ cli application ์ด๋‹ค.

๋˜ํ•œ ๋ชจ๋“  ๋กœ์ง์€ mysql sequelize๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์ƒ์„ฑ๋˜์—ˆ์œผ๋ฉฐ ๋‹ค๋ฅธ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•˜๋Š” ๊ฒฝ์šฐ /bin/dddgen ํŒŒ์ผ์„ ์ˆ˜์ •ํ•˜์—ฌ์•ผ ํ•œ๋‹ค.

Getting started

๋จผ์ € ์ƒ์„ฑํ•œ ์Šคํฌ๋ฆฝํŠธ ํŒŒ์ผ์„ ์ฝ์–ด๋“ค์ด๊ธฐ ์œ„ํ•ด ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ ์„ค์ •ํ•œ๋‹ค.

export PATH=/Users/namhoonlee/Desktop/git/ddd-api-generator/bin:$PATH

์œ„ ๋ช…๋ น์–ด๋Š” ํŠน์ • ๋””๋ ‰ํ† ๋ฆฌ์˜ ๋กœ์ปฌ ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์ด๋ฏ€๋กœ ์ „์—ญ์œผ๋กœ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š”

/.bash_profile ํŒŒ์ผ์— ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ ๋“ฑ๋กํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค.

Command

dddgen generate <component>

component์˜ ์ข…๋ฅ˜ repo repository interface ๋ฅผ ์ƒ์„ฑํ•ด ์ค€๋‹ค.

repoimpl repository ๊ตฌํ˜„์ฒด๋ฅผ ์ƒ์„ฑํ•ด ์ค€๋‹ค.

route route๋ฅผ ์ƒ์„ฑํ•ด ์ค€๋‹ค.

all ํŠน์ • ๋„๋ฉ”์ธ์— ๋Œ€ํ•ด ์œ„ ๋ชจ๋“  ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ƒ์„ฑํ•ด ์ค€๋‹ค.

์œ„ ๋ช…๋ น์–ด๋Š” DDD ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋ช…๋ น์–ด์ด๋ฉฐ ๋‹ค์Œ์˜ ํ•„์ˆ˜ ์˜ต์…˜์„ ๊ฐ€์ง„๋‹ค.

-n <domain>

์—ฌ๊ธฐ์„œ domain ๋ช…์€ ๋‹จ์ˆ˜์ด๋ฉฐ, ๋‘ ๋‹จ์–ด ์ด์ƒ์ธ ๊ฒฝ์šฐ sales-proposal ์™€ ๊ฐ™์ด ๊ฐ€์šด๋ฐ ๋ฐ”(-) ๋กœ ๊ตฌ๋ถ„ํ•ด ์ค€๋‹ค.

example

dddgen generate repository -n user
dddgen generate all -n user

Configuration

๊ฐ ์ปดํฌ๋„ŒํŠธ๋“ค์˜ ๊ธฐ๋ณธ ๊ฒฝ๋กœ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

repository: ./src/domain/[๋„๋ฉ”์ธ ๋ช…]/[๋„๋ฉ”์ธ ๋ช…].repository.ts

repository implementation: ./src/infra/sequelize/mysql/repositories/[๋„๋ฉ”์ธ ๋ช…].repository.impl.ts

route: ./src/interfaces/http/[๋„๋ฉ”์ธ ๋ช…].route.ts

ํ•ด๋‹น ๊ฒฝ๋กœ๋ฅผ ์œ„ํ•œ ๋””๋ ‰ํ† ๋ฆฌ๋“ค์ด ๋ชจ๋‘ ์ƒ์„ฑ๋˜์–ด ์žˆ์–ด์•ผ ํ•˜๋ฉฐ, ์ด๋ฅผ ์ˆ˜์ •ํ•˜๊ณ ์ž ํ•œ๋‹ค๋ฉด dddgen ํŒŒ์ผ์˜ repoPath, repoImplPath, routePath๋ฅผ ์ˆ˜์ •ํ•ด ์ฃผ๋ฉด ๋œ๋‹ค.

About

Generate DDD component for nodejs server with typescript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published