Skip to content

Code-4-Community/scaffolding

Repository files navigation

Scaffolding

This workspace has been generated by Nx, a Smart, fast and extensible build system.

Setup

Clone this repo and run yarn at the root to install this project's dependencies.

You can optionally install nx globally with npm install -g nx - if you don't, you'll just need to prefix the commands below with npx (e.g. npx nx serve frontend).

Start the app

To start the development server run nx serve frontend. Open your browser and navigate to http://localhost:4200/. Happy coding!

Running tasks

To run just the frontend (port 4200):

nx serve frontend

To run just the backend (port 3000):

nx serve backend

To run both the frontend and backend with one command:

nx run-many -t serve -p frontend backend

Swagger

The backend can expose Swagger UI (built from an OpenAPI document via @nestjs/swagger) so you can browse and try HTTP routes without reading controller code first.

Turn it on: In .env at the repo root (copy from example.env), set SWAGGER_ENABLED=true. Restart the backend (nx serve backend), then open http://localhost:3000/api for the UI.

Turn it off: Unset SWAGGER_ENABLED or set it to false.

TL TODOS:

  1. In apps/backend/src/main.ts, replace [YOUR_APP_NAME] and other [TL] strings, adjust .addTag() entries to match your controllers,
  2. Add @ApiBearerAuth() onto the controller or handler for specifically protected routes. addBearerAuth() only states that the application supports authentication via HTTP Bearer in the Authorization header, it doesn't mark specific routes as protected. Learn more

Decorators to know as you add routes! (import from @nestjs/swagger):

  • @ApiProperty() / @ApiPropertyOptional(): on top of DTO fields
  • @ApiTags('Name'): on top of controllers to tag them to specific tags/features
  • @ApiHeader({name: '...', description: '...'}): on top of individual methods or controllers to define custom headers that are expected as part of the requests to those methods/controllers
  • @ApiResponse({ status: '...', description: '...' }): to define a custom HTTP response.

More Decorators.

Other commands

Run git submodule update --remote to pull the latest changes from the component library

When cloning the repo, make sure to add the --recurse-modules flag to also clone the component library submodule (e.g. git clone --recurse-submodules https://github.com/Code-4-Community/scaffolding.git for the scaffolding repo)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors