api_graphql_generating - wwwsolutions/nestjs-starter-kit GitHub Wiki

Nx NestJs Starter

CODE SNIPPETS ::: Create project structure

Workspace

// generate workspace
npx create-nx-workspace@latest --name=wwwsolutions-nest-starter --preset=empty --pm=yarn --npm-scope=wwwsolutions --nx-cloud=false

// rename wwwsolutions --> wwwsolutions-nest-starter

cd wwwsolutions-nest-starter

// Install the "json" utility
yarn add json --global

// Set the base branch to "main"
json -I -f nx.json -e "this.affected.defaultBase = 'main';"

// rename 'master' branch --> 'main'
git branch -m master main

Application

yarn add -D @nrwl/nest
nx generate @nrwl/nest:application --name=api --standaloneConfig --tags=scope:graphql,type:api --no-interactive

API core libs

CONFIG

app
nx generate @nrwl/nest:library --name=app --directory=api/graphql/config --buildable --standaloneConfig --strict --tags=type:config,scope:graphql --no-interactive
features
nx generate @nrwl/nest:library --name=features --directory=api/graphql/config --buildable --standaloneConfig --strict --tags=type:config,scope:graphql --no-interactive
docker
nx generate @nrwl/workspace:library --name=docker --directory=api/graphql/config --buildable --standaloneConfig --strict --tags=type:config,scope:graphql --testEnvironment=node --unitTestRunner=none --no-interactive
codegen
nx generate @nrwl/workspace:library --name=codegen --directory=api/graphql/config --buildable --standaloneConfig --strict --tags="type:config","scope:graphql" --testEnvironment=node --unitTestRunner=none --no-interactive

CORE

core
nx generate @nrwl/nest:library --name=core --directory=api/graphql --buildable --service --standaloneConfig --strict --tags=type:config,scope:graphql --no-interactive

DATA-ACCESS

models
nx generate @nrwl/nest:library --name=models --directory=api/graphql/data-access --buildable --standaloneConfig --strict --tags=type:data-access,scope:graphql --no-interactive
core
nx generate @nrwl/nest:library --name=core --directory=api/graphql/data-access --buildable --standaloneConfig --strict --tags=type:data-access,scope:graphql --no-interactive
prisma
nx generate @nrwl/nest:library --name=prisma --directory=api/graphql/data-access --buildable --standaloneConfig --strict --tags=type:data-access,scope:graphql --no-interactive

SHARED

utils
nx generate @nrwl/nest:library --name=utils --directory=shared --buildable --standaloneConfig --strict --tags=type:util,scope:graphql --no-interactive

FEATURE

Disperse DDD structure {a} --> feature{a} + data-access{a}

users
nx generate @nrwl/nest:library --name=feature --directory=api/graphql/users --buildable --standaloneConfig --strict --tags=type:feature,scope:graphql --no-interactive
nx generate @nrwl/nest:library --name=data-access --directory=api/graphql/users --buildable --standaloneConfig --strict --tags=type:data-access,scope:graphql --no-interactive
authentication
nx generate @nrwl/nest:library --name=feature --directory=api/graphql/authentication --buildable --standaloneConfig --strict --tags=type:feature,scope:graphql --no-interactive
nx generate @nrwl/nest:library --name=data-access --directory=api/graphql/authentication --buildable --standaloneConfig --strict --tags=type:data-access,scope:graphql --no-interactive
courses
nx generate @nrwl/nest:library --name=feature --directory=api/graphql/courses --buildable --standaloneConfig --strict --tags=type:feature,scope:graphql --no-interactive
nx generate @nrwl/nest:library --name=data-access --directory=api/graphql/courses --buildable --standaloneConfig --strict --tags=type:data-access,scope:graphql --no-interactive
nx generate @nrwl/nest:service --name=courses --project=api-graphql-courses-data-access --directory=lib --flat --no-interactive
⚠️ **GitHub.com Fallback** ⚠️