### Start Gateway Application Source: https://github.com/nestjs/nest/blob/master/sample/31-graphql-federation-code-first/README.md Navigate to the gateway directory and start the server. Ensure all sub-graphs are running before starting the gateway. ```sh cd gateway && npm run start ``` -------------------------------- ### Start Users Sub-graph Application Source: https://github.com/nestjs/nest/blob/master/sample/31-graphql-federation-code-first/README.md Navigate to the users application directory and start the server. This sub-graph must be running before the gateway. ```sh cd users-application && npm run start ``` -------------------------------- ### Start Development Server Source: https://github.com/nestjs/nest/blob/master/sample/22-graphql-prisma/README.md Starts the NestJS application in development mode. ```bash npm run start:dev ``` -------------------------------- ### Start the NestJS application Source: https://github.com/nestjs/nest/blob/master/sample/05-sql-typeorm/README.md Executes the standard start script to launch the application server. ```bash npm run start ``` -------------------------------- ### Install project dependencies Source: https://github.com/nestjs/nest/blob/master/sample/05-sql-typeorm/README.md Run this command to install all necessary packages for the NestJS application. ```bash npm install ``` -------------------------------- ### Start Posts Sub-graph Application Source: https://github.com/nestjs/nest/blob/master/sample/31-graphql-federation-code-first/README.md Navigate to the posts application directory and start the server. This sub-graph must be running before the gateway. ```sh cd posts-application && npm run start ``` -------------------------------- ### Start Federation Applications Source: https://github.com/nestjs/nest/blob/master/sample/32-graphql-federation-schema-first/README.md Execute these commands in sequence to start the sub-graphs and then the gateway. Sub-graphs must be running first so the gateway can successfully fetch their schemas. ```sh cd users-application && npm run start ``` ```sh cd posts-application && npm run start ``` ```sh cd gateway && npm run start ``` -------------------------------- ### Install Dependencies for NestJS Development Source: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md Run this command after cloning the repository to install all necessary project dependencies. ```bash $ npm ci --legacy-peer-deps # (or yarn install) ``` -------------------------------- ### Install NestJS Project Dependencies Source: https://github.com/nestjs/nest/blob/master/sample/28-sse/README.md Install all npm dependencies required for the NestJS project. ```bash $ npm install ``` -------------------------------- ### NestJS Commit Message Format Examples Source: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md Illustrative examples of properly formatted Git commit messages, demonstrating the use of type, scope, and subject. ```text docs(changelog): update change log to beta.5 ``` ```text fix(core): need to depend on latest rxjs and zone.js ``` -------------------------------- ### Manage Docker containers Source: https://github.com/nestjs/nest/blob/master/sample/05-sql-typeorm/README.md Commands to start and stop the local MySQL database environment using Docker Compose. ```bash docker-compose up ``` ```bash docker-compose down ``` -------------------------------- ### Run NestJS Application in Development Mode Source: https://github.com/nestjs/nest/blob/master/sample/32-graphql-federation-schema-first/posts-application/README.md Starts the application in development mode. ```bash # development $ npm run start ``` -------------------------------- ### Run NestJS Application in Production Mode Source: https://github.com/nestjs/nest/blob/master/sample/32-graphql-federation-schema-first/posts-application/README.md Starts the application in production mode. ```bash # production mode $ npm run start:prod ``` -------------------------------- ### Execute NestJS File Upload Source: https://github.com/nestjs/nest/blob/master/sample/29-file-upload/README.md Start the application and use curl to upload a file as multipart/form-data. ```sh npm run start # OR npm run start:dev # in another terminal curl http://localhost:3000/file -F 'file=@./package.json' -F 'name=test' ``` -------------------------------- ### Run NestJS Application in Different Modes Source: https://github.com/nestjs/nest/blob/master/sample/28-sse/README.md Start the NestJS application in development, watch, or production mode. Use watch mode during development for automatic restarts on file changes. ```bash # development $ npm run start ``` ```bash # watch mode $ npm run start:dev ``` ```bash # production mode $ npm run start:prod ``` -------------------------------- ### Query Combined User and Posts Data Source: https://github.com/nestjs/nest/blob/master/sample/31-graphql-federation-code-first/README.md Example GraphQL query to fetch user details along with their associated posts from the federated gateway. This query demonstrates how data from different sub-graphs is combined. ```gql query getUserWithPosts($userId: ID!) { getUser(id: $userId) { id name posts { authorId id title } } } ``` -------------------------------- ### Run NestJS Application in Watch Mode Source: https://github.com/nestjs/nest/blob/master/sample/32-graphql-federation-schema-first/posts-application/README.md Starts the application in watch mode, automatically recompiling on file changes. ```bash # watch mode $ npm run start:dev ``` -------------------------------- ### Basic Socket.IO Client Connection and Event Handling Source: https://github.com/nestjs/nest/blob/master/sample/02-gateways/client/index.html This snippet shows how to initialize a Socket.IO client, connect to a server, emit custom events, and set up listeners for connection status, custom events, and exceptions. ```javascript const socket = io('http://localhost:3000'); socket.on('connect', function() { console.log('Connected'); socket.emit('events', { test: 'test' }); socket.emit('identity', 0, response => console.log('Identity:', response), ); }); socket.on('events', function(data) { console.log('event', data); }); socket.on('exception', function(data) { console.log('event', data); }); socket.on('disconnect', function() { console.log('Disconnected'); }); ``` -------------------------------- ### Prepare NestJS Development Environment Source: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md Execute this script to compile packages and move them to sample directories, setting up the environment for development. ```bash $ sh scripts/prepare.sh ``` -------------------------------- ### Build All NestJS Packages Source: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md Compiles all project packages and places them into the 'sample' directories. ```bash $ npm run build ``` -------------------------------- ### Push Prisma Database Schema Source: https://github.com/nestjs/nest/blob/master/sample/22-graphql-prisma/README.md Applies the Prisma schema to the database, creating tables and syncing the schema. ```bash npx prisma db push ``` -------------------------------- ### Run NestJS Integration Tests Source: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md Initiates the integration tests; Docker is a prerequisite for running this script. ```bash $ sh scripts/run-integration.sh ``` -------------------------------- ### WebSocket Client Connection with Event Messaging Source: https://github.com/nestjs/nest/blob/master/sample/16-gateways-ws/client/index.html Establishes a WebSocket connection to a local server, sends a JSON event payload on connection, and logs received messages. Use this pattern to initialize a WebSocket client and implement basic bidirectional communication. ```JavaScript const socket = new WebSocket('ws://localhost:8080'); socket.onopen = function() { console.log('Connected'); socket.send( JSON.stringify({ event: 'events', data: 'test', }), ); socket.onmessage = function(data) { console.log(data); }; }; ``` -------------------------------- ### Listen to SSE events in the browser Source: https://github.com/nestjs/nest/blob/master/sample/28-sse/src/index.html Connects to a '/sse' endpoint and appends received data as list items to the document body. ```javascript const eventSource = new EventSource('/sse'); eventSource.onmessage = ({ data }) => { const message = document.createElement('li'); message.innerText = 'New message: ' + data; document.body.appendChild(message); } ``` -------------------------------- ### Run Unit Tests for NestJS Application Source: https://github.com/nestjs/nest/blob/master/sample/32-graphql-federation-schema-first/posts-application/README.md Executes the unit tests for the project. ```bash # unit tests $ npm run test ``` -------------------------------- ### Run NestJS Unit Tests Source: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md Executes the complete suite of unit tests for the project. ```bash $ npm run test ``` -------------------------------- ### Build NestJS Packages for Production Source: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md Compiles all packages and places the output files alongside their source .ts files, typically for production builds. ```bash $ npm run build:prod ``` -------------------------------- ### Run End-to-End Tests for NestJS Application Source: https://github.com/nestjs/nest/blob/master/sample/32-graphql-federation-schema-first/posts-application/README.md Executes the end-to-end tests for the project. ```bash # e2e tests $ npm run test:e2e ``` -------------------------------- ### Run NestJS Test Suites Source: https://github.com/nestjs/nest/blob/master/sample/28-sse/README.md Execute unit tests, end-to-end tests, or generate test coverage reports for the NestJS application. ```bash # unit tests $ npm run test ``` ```bash # e2e tests $ npm run test:e2e ``` ```bash # test coverage $ npm run test:cov ``` -------------------------------- ### Generate Test Coverage Report for NestJS Application Source: https://github.com/nestjs/nest/blob/master/sample/32-graphql-federation-schema-first/posts-application/README.md Generates a test coverage report for the project. ```bash # test coverage $ npm run test:cov ``` -------------------------------- ### Run NestJS Linter Source: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md Performs linting across the codebase to enforce coding style and identify potential issues. ```bash $ npm run lint ``` -------------------------------- ### Rebase and Force Push After PR Changes Source: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md After making required updates and re-running tests, rebase your branch interactively with master and then force push to update your Pull Request on GitHub. ```shell git rebase master -i ``` ```shell git push -f ``` -------------------------------- ### Generate GraphQL Typings Source: https://github.com/nestjs/nest/blob/master/sample/22-graphql-prisma/README.md Generates TypeScript type definitions based on the GraphQL schema. ```bash npm run generate:typings ``` -------------------------------- ### Create a New Git Branch for a Fix Source: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md Use this command to create and switch to a new branch named 'my-fix-branch' based on the 'master' branch before making changes. ```shell git checkout -b my-fix-branch master ``` -------------------------------- ### Configure Fastify Listen Address for Remote Machine Source: https://github.com/nestjs/nest/blob/master/sample/10-fastify/README.md Set the listen address to 0.0.0.0 when running the NestJS app on a remote machine to accept connections from any network interface. Use this instead of the default localhost binding. ```typescript await app.listen(3000, '0.0.0.0') ``` -------------------------------- ### Commit Changes with a Descriptive Message Source: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md Commit all staged and modified files with a descriptive message. The '-a' option automatically stages modified and deleted files. ```shell git commit -a ``` -------------------------------- ### Push Local Branch to GitHub Remote Source: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md Push your local 'my-fix-branch' to the 'origin' remote repository on GitHub. ```shell git push origin my-fix-branch ``` -------------------------------- ### Switch to Master Branch Forcefully Source: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md Switch to the 'master' branch, discarding any local changes if necessary, after a pull request is merged. ```shell git checkout master -f ``` -------------------------------- ### NestJS Commit Message Format Structure Source: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md Defines the required structure for Git commit messages, including header, body, and footer, with specific rules for type, scope, and subject. ```text (): \n\n\n\n