### Nest Admin Project Setup and Development Source: https://github.com/taozhi1010/nest-admin/blob/master/admin/README.md Instructions for cloning the Nest Admin repository, installing dependencies using npm (including a workaround for slow downloads), and starting the development server. It also notes that the Vue 2 version is no longer maintained. ```bash # 克隆项目 git clone https://github.com/taozhi1010/nest-admin # 进入项目目录 cd admin # 安装依赖 npm install # 建议不要直接使用 cnpm 安装依赖,会有各种诡异的 bug。可以通过如下操作解决 npm 下载速度慢的问题 npm install --registry=https://registry.npmmirror.com # 启动服务 npm run dev 浏览器访问 http://localhost:80 ``` -------------------------------- ### Deploy and Start NestJS Project with PM2 Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/pm2.md Steps to deploy a packaged NestJS project, install dependencies, and start the application using PM2. This includes creating a directory for the project, extracting the archive, installing npm packages, and running the application. ```bash mkdir -p /server/soft/nest-admin sudo tar -xvf nest-server.tar -C /server/soft/nest-admin cd /server/soft/nest-admin/server/ npm install cd /server/soft/nest-admin/server/dist pm2 start main.js ``` -------------------------------- ### Install MySQL Server Components Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/mysql.md Installs the common, libraries, client, and server components of MySQL 5.7.26, followed by ncurses libraries. ```bash rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm yum install libncurses* ``` -------------------------------- ### Start Redis Server Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/redis.md Starts the Redis server using the specified configuration file. ```bash cd /server/soft/redis/redis-7.0.1/ redis-server redis.conf ``` -------------------------------- ### Start MySQL Service and Check Process Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/mysql.md Starts the MySQL service and then checks for running MySQL processes to confirm successful startup. ```bash systemctl start mysqld.service ps -ef |grep mysql ``` -------------------------------- ### Install Dependencies and Run Nest-Admin Source: https://github.com/taozhi1010/nest-admin/blob/master/README.md Installs project dependencies using yarn and starts the Nest-Admin development server. ```shell cd nest-admin && yarn yarn start:dev ``` -------------------------------- ### Install and Manage Nginx on OpenCloudOS Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/nginx.md Commands for installing, starting, enabling, and checking the status of Nginx on OpenCloudOS using yum and systemctl. ```bash sudo yum update sudo yum install epel-release sudo yum install nginx sudo systemctl start nginx sudo systemctl enable nginx sudo systemctl status nginx ``` -------------------------------- ### Compile and Install Redis Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/redis.md Navigates to the extracted Redis directory, compiles the source code, and installs Redis on the system. ```bash cd /server/soft/redis/redis-7.0.1 make make install ``` -------------------------------- ### Install and Configure PM2 Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/pm2.md Instructions for installing the PM2 process manager globally using npm and setting up a symbolic link for PM2 command execution. ```bash npm install pm2 -g sudo ln -s /server/soft/node/node-v20.5.0-linux-x64/bin/pm2 /usr/bin/pm2 ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/taozhi1010/nest-admin/blob/master/server/README.md Installs the project's dependencies using Yarn. Ensure you have Yarn installed globally. ```bash yarn install ``` -------------------------------- ### Run Nest Admin Development Server Source: https://github.com/taozhi1010/nest-admin/blob/master/admin-vue3/README.md Starts the Nest Admin development server and provides the URL to access the application in a web browser. ```bash npm run dev # Access at http://localhost:8888 ``` -------------------------------- ### Create MySQL Directory Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/mysql.md Creates a directory structure for MySQL installation in the server's soft directory. ```bash cd / mkdir -p server/soft/mysql ``` -------------------------------- ### Run NestJS Application Source: https://github.com/taozhi1010/nest-admin/blob/master/server/README.md Commands to run the NestJS application. 'start' runs it in development mode, and 'start:dev' enables watch mode for automatic restarts on file changes. 'start:prod' is for production deployment. ```bash yarn run start yarn run start:dev yarn run start:prod ``` -------------------------------- ### Nginx Configuration for Web Applications Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/nginx.md Example Nginx server block configuration for serving a web application, including handling static files and client-side routing with `try_files`. ```nginx server { listen 80; server_name admin.crazystudent13.cn; location / { root /server/website/dist; try_files $uri $uri/ /index.html; index index.html; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } ``` -------------------------------- ### Create Redis Download Directory Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/redis.md Creates a directory for downloading and storing Redis installation files. ```bash cd / mkdir -p server/soft/redis cd /server/soft/redis ``` -------------------------------- ### Download MySQL Package Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/mysql.md Downloads the MySQL 5.7.26 RPM bundle from the specified URL. ```bash wget http://dev.mysql.com/get/mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar ``` -------------------------------- ### Verify Redis Version Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/redis.md Checks the installed Redis version to confirm successful installation. ```bash redis-server --version ``` -------------------------------- ### Clone and Install Nest Admin Dependencies Source: https://github.com/taozhi1010/nest-admin/blob/master/admin-vue3/README.md Clones the Nest Admin repository and installs project dependencies using npm. It also provides a workaround for slow npm download speeds by using a mirror registry. ```bash git clone https://github.com/taozhi1010/nest-admin cd admin npm install npm install --registry=https://registry.npmmirror.com ``` -------------------------------- ### Install Node.js on Linux Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/pm2.md Steps to download, extract, and configure Node.js on a Linux server. This includes creating necessary directories, downloading the Node.js archive, extracting it, and setting up symbolic links for global access to node, npm, and npx. ```bash mkdir -p /server/soft/node cd /server/soft/node wget https://nodejs.org/dist/v20.5.0/node-v20.5.0-linux-x64.tar.xz sudo tar -xJvf node-v20.5.0-linux-x64.tar.xz -C /server/soft/node # Create symbolic links (recommended) sudo ln -s /server/soft/node/node-v20.5.0-linux-x64/bin/node /usr/bin/node sudo ln -s /server/soft/node/node-v20.5.0-linux-x64/bin/npm /usr/bin/npm sudo ln -s /server/soft/node/node-v20.5.0-linux-x64/bin/npx /usr/bin/npx # Verify installation node -v npm -v ``` -------------------------------- ### Check for Existing MariaDB Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/mysql.md Checks if MariaDB is already installed on the system using rpm. ```bash rpm -qa | grep mari ``` -------------------------------- ### PM2 Process Management Commands Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/pm2.md A collection of essential PM2 commands for managing Node.js processes, including starting, stopping, restarting, listing, monitoring, and logging processes. ```javascript pm2 start app.js pm2 restart app.js pm2 stop app.js pm2 list pm2 monit pm2 logs pm2 stop all pm2 restart all pm2 reload all pm2 stop 0 pm2 restart 0 pm2 startup pm2 web pm2 delete 0 pm2 delete all ``` -------------------------------- ### Install Dependencies with Yarn Source: https://github.com/taozhi1010/nest-admin/blob/master/README.zh-CN.md This snippet demonstrates how to install project dependencies using Yarn after cloning the repository. ```shell cd nest-admin && yarn ``` -------------------------------- ### Database Connection Setup Source: https://github.com/taozhi1010/nest-admin/blob/master/admin-vue3/html/ie.html Illustrates how to establish a database connection within a NestJS application, likely using a TypeORM or Mongoose integration. This snippet would show the module setup for database connectivity. ```typescript import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; @Module({ imports: [ TypeOrmModule.forRoot({ type: 'postgres', host: process.env.DB_HOST, port: parseInt(process.env.DB_PORT, 10) || 5432, username: process.env.DB_USERNAME, password: process.env.DB_PASSWORD, database: process.env.DB_NAME, autoLoadEntities: true, synchronize: true, }), ], }) export class DatabaseModule {} ``` -------------------------------- ### Database Connection Setup Source: https://github.com/taozhi1010/nest-admin/blob/master/admin/public/html/ie.html Illustrates how to establish a database connection within a NestJS application, likely using a TypeORM or Mongoose integration. This snippet would show the module setup for database connectivity. ```typescript import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; @Module({ imports: [ TypeOrmModule.forRoot({ type: 'postgres', host: process.env.DB_HOST, port: parseInt(process.env.DB_PORT, 10) || 5432, username: process.env.DB_USERNAME, password: process.env.DB_PASSWORD, database: process.env.DB_NAME, autoLoadEntities: true, synchronize: true, }), ], }) export class DatabaseModule {} ``` -------------------------------- ### Troubleshooting Nginx Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/nginx.md Commands to check Nginx configuration syntax and view error logs for troubleshooting. ```bash sudo nginx -t tail -f /var/log/nginx/error.log ``` -------------------------------- ### Nest-Admin Database Initialization Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/step.md This SQL script initializes the database for the Nest-Admin project. It should be executed using a database management tool like Navicat Premium Lite. ```SQL /* nest-admin/server/db/init.sql This script initializes the database for the nest-admin project. Execute this script in your MySQL client. */ -- Example table creation (replace with actual schema from init.sql) CREATE TABLE IF NOT EXISTS users ( id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(255) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); -- Example data insertion (replace with actual data from init.sql) INSERT INTO users (username, password) VALUES ('admin', 'hashed_password'); ``` -------------------------------- ### Build Nest Admin for Staging and Production Source: https://github.com/taozhi1010/nest-admin/blob/master/admin-vue3/README.md Builds the Nest Admin project for either the staging or production environment. ```bash npm run build:stage npm run build:prod ``` -------------------------------- ### Nest Admin Project Deployment Builds Source: https://github.com/taozhi1010/nest-admin/blob/master/admin/README.md Commands to build the Nest Admin project for different environments, specifically for testing (staging) and production. ```bash # 构建测试环境 npm run build:stage # 构建生产环境 npm run build:prod ``` -------------------------------- ### Configure Firewall with UFW Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/redis.md Installs, enables, and configures UFW (Uncomplicated Firewall) to allow TCP traffic on port 6379. ```bash yum update yum install ufw yum enable ufw ufw allow 6379/tcp ``` -------------------------------- ### Connect to MySQL Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/mysql.md Connects to the MySQL server as the root user, prompting for a password. ```sql mysql -u root -p ``` -------------------------------- ### Find Nginx Configuration File Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/nginx.md Commands to locate the Nginx configuration file (`nginx.conf`) on the system. ```bash ps -ef | grep nginx find / -name nginx.conf find /etc -name nginx.conf ``` -------------------------------- ### Extract MySQL Package Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/mysql.md Extracts the contents of the downloaded MySQL RPM bundle tarball. ```bash tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar ``` -------------------------------- ### Download and Extract Redis Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/redis.md Downloads the Redis 7.0.1 tarball using wget and then extracts the archive. ```bash wget https://download.redis.io/releases/redis-7.0.1.tar.gz tar -xvf redis-7.0.1.tar.gz ``` -------------------------------- ### Find Redis Configuration File Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/redis.md Locates the 'redis.conf' file on the system. ```bash find / -name "redis.conf" ``` -------------------------------- ### Admin Controller Example Source: https://github.com/taozhi1010/nest-admin/blob/master/admin-vue3/html/ie.html An example of an AdminController in NestJS, handling HTTP requests for admin-related operations. It likely interacts with the AdminService to perform business logic. ```typescript import { Controller, Get } from '@nestjs/common'; import { AdminService } from './admin.service'; @Controller('admin') export class AdminController { constructor(private readonly adminService: AdminService) {} @Get() getAdminData(): string { return this.adminService.getAdminData(); } } ``` -------------------------------- ### Admin Controller Example Source: https://github.com/taozhi1010/nest-admin/blob/master/admin/public/html/ie.html An example of an AdminController in NestJS, handling HTTP requests for admin-related operations. It likely interacts with the AdminService to perform business logic. ```typescript import { Controller, Get } from '@nestjs/common'; import { AdminService } from './admin.service'; @Controller('admin') export class AdminController { constructor(private readonly adminService: AdminService) {} @Get() getAdminData(): string { return this.adminService.getAdminData(); } } ``` -------------------------------- ### Restart Nginx Service Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/nginx.md Command to restart the Nginx service after configuration changes. ```bash sudo systemctl restart nginx ``` -------------------------------- ### Restart Redis Service Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/redis.md Restarts the Redis service using systemctl. ```shell systemctl restart redis ``` -------------------------------- ### View Temporary MySQL Root Password Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/mysql.md Retrieves the temporary root password generated by MySQL during its initial startup by searching the mysqld.log file. ```bash grep "password" /var/log/mysqld.log ``` -------------------------------- ### Remove MariaDB Packages Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/mysql.md Removes MariaDB connector packages if they exist, using rpm to bypass dependencies. ```bash rpm -e --nodeps mariadb-connector-c-3.1.11-2.oc8.1.x86_64 rpm -e --nodeps mariadb-connector-c-config-3.1.11-2.oc8.1.noarch ``` -------------------------------- ### Redis Sorted Set Commands Source: https://github.com/taozhi1010/nest-admin/blob/master/admin/public/html/ie.html This section details common Redis commands for managing sorted sets, including adding members, removing members, and retrieving ranges of members. It covers parameters, return values, and usage examples for each command. ```APIDOC ZREM key member [member ...] - Removes members from a sorted set - Parameters: - key: The sorted set key - member: Members to remove - Returns: Number of members removed ZRANGE key start stop [BYSCORE|BYLEX] [REV] [LIMIT offset count] [WITHSCORES] - Returns a range of members - Parameters: - key: The sorted set key - start: The starting index or score - stop: The ending index or score - BYSCORE: Sort by score - BYLEX: Sort by lexicographical order - REV: Reverse the order - LIMIT offset count: Limit the number of returned elements - WITHSCORES: Include scores in the output - Returns: List of members in the specified range ``` -------------------------------- ### Redis Sorted Set Commands Source: https://github.com/taozhi1010/nest-admin/blob/master/admin-vue3/html/ie.html This section details common Redis commands for managing sorted sets, including adding members, removing members, and retrieving ranges of members. It covers parameters, return values, and usage examples for each command. ```APIDOC ZREM key member [member ...] - Removes members from a sorted set - Parameters: - key: The sorted set key - member: Members to remove - Returns: Number of members removed ZRANGE key start stop [BYSCORE|BYLEX] [REV] [LIMIT offset count] [WITHSCORES] - Returns a range of members - Parameters: - key: The sorted set key - start: The starting index or score - stop: The ending index or score - BYSCORE: Sort by score - BYLEX: Sort by lexicographical order - REV: Reverse the order - LIMIT offset count: Limit the number of returned elements - WITHSCORES: Include scores in the output - Returns: List of members in the specified range ``` -------------------------------- ### Run NestJS Tests Source: https://github.com/taozhi1010/nest-admin/blob/master/server/README.md Commands to execute tests for the NestJS application. Includes commands for unit tests, end-to-end (e2e) tests, and test coverage reports. ```bash yarn run test yarn run test:e2e yarn run test:cov ``` -------------------------------- ### Contribution Guidelines Source: https://github.com/taozhi1010/nest-admin/blob/master/README.md Instructions for contributing to the Nest-Admin project, including using the project, reporting issues, and submitting pull requests. ```markdown Any type of contribution is welcome, here are some examples of how you may contribute to this project: - Use Ant Design Pro in your daily work. - Submit [issues](https://github.com/taozhi1010/nest-admin/issues) to report bugs or ask questions. - Propose [pull requests](https://github.com/taozhi1010/nest-admin/pulls) to improve our code. ``` -------------------------------- ### Clone Nest-Admin Repository Source: https://github.com/taozhi1010/nest-admin/blob/master/README.md Clones the Nest-Admin project from GitHub to your local machine. ```shell git clone git@github.com:taozhi1010/nest-admin.git ``` -------------------------------- ### Related Projects Source: https://github.com/taozhi1010/nest-admin/blob/master/README.md A list of related projects, primarily focused on low-code platforms, visualization solutions, and JavaScript utility libraries, with links to their respective GitHub repositories. ```markdown | name | Description | | ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | | [H5-Dooring](https://github.com/MrXujiang/h5-Dooring) | 让 H5 制作像搭积木一样简单, 轻松搭建 H5 页面, H5 网站, PC 端网站, LowCode 平台. | | [V6.Dooring](https://github.com/MrXujiang/v6.dooring.public) | 可视化大屏解决方案, 提供一套可视化编辑引擎, 助力个人或企业轻松定制自己的可视化大屏应用. | | [dooring-electron-lowcode](https://github.com/MrXujiang/dooring-electron-lowcode) | 基于 electron 的 H5-Dooring 编辑器桌面端. | | [DooringX](https://github.com/H5-Dooring/dooringx) | 快速高效搭建可视化拖拽平台. | | [Mitu](https://github.com/H5-Dooring/mitu-editor) | 一款轻量级且可扩展的图片/图形编辑器解决方案. | | [xijs](https://github.com/MrXujiang/xijs) | 一个开箱即用的面向业务的 javascript 工具库 | ``` -------------------------------- ### Reconnect to MySQL with New Password Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/mysql.md Attempts to connect to the MySQL server using the root user and the newly set password. ```sql mysql -u root -p ``` -------------------------------- ### HTTP Request Handling Source: https://github.com/taozhi1010/nest-admin/blob/master/admin/public/html/ie.html Demonstrates handling HTTP requests and responses in a NestJS controller. This snippet would typically show how to define routes, accept request parameters, and return data. ```typescript import { Controller, Get, Post, Body, Param, Put, Delete } from '@nestjs/common'; import { AppService } from './app.service'; @Controller('items') export class AppController { constructor(private readonly appService: AppService) {} @Get() findAll(): string { return this.appService.getHello(); } @Post() create(@Body() createItemDto) { return `This action adds a new item with name: ${createItemDto.name}`; } @Get(':id') findOne(@Param('id') id: string): string { return `This action returns item #${id}`; } @Put(':id') update(@Param('id') id: string, @Body() updateItemDto) { return `This action updates item #${id}`; } @Delete(':id') remove(@Param('id') id: string) { return `This action removes item #${id}`; } } ``` -------------------------------- ### HTTP Request Handling Source: https://github.com/taozhi1010/nest-admin/blob/master/admin-vue3/html/ie.html Demonstrates handling HTTP requests and responses in a NestJS controller. This snippet would typically show how to define routes, accept request parameters, and return data. ```typescript import { Controller, Get, Post, Body, Param, Put, Delete } from '@nestjs/common'; import { AppService } from './app.service'; @Controller('items') export class AppController { constructor(private readonly appService: AppService) {} @Get() findAll(): string { return this.appService.getHello(); } @Post() create(@Body() createItemDto) { return `This action adds a new item with name: ${createItemDto.name}`; } @Get(':id') findOne(@Param('id') id: string): string { return `This action returns item #${id}`; } @Put(':id') update(@Param('id') id: string, @Body() updateItemDto) { return `This action updates item #${id}`; } @Delete(':id') remove(@Param('id') id: string) { return `This action removes item #${id}`; } } ``` -------------------------------- ### NestJS Application Configuration Source: https://github.com/taozhi1010/nest-admin/blob/master/admin/public/html/ie.html Demonstrates how to configure a NestJS application, likely involving environment variables or configuration files. This snippet would typically show how to load and access configuration settings within the application. ```typescript import { Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true, envFilePath: '.env', }), ], }) export class AppConfigModule {} ``` -------------------------------- ### Modify MySQL Host Configuration Source: https://github.com/taozhi1010/nest-admin/blob/master/docs/deploy-online/mysql.md Updates the MySQL user table to allow the root user to connect from any host ('%') instead of just localhost, then flushes privileges. ```sql use mysql; UPDATE user SET Host = '%' WHERE User = 'root'; flush privileges; ``` -------------------------------- ### Admin Service Example Source: https://github.com/taozhi1010/nest-admin/blob/master/admin-vue3/html/ie.html A basic implementation of an AdminService in NestJS, responsible for the core business logic of the admin module. This service would typically be injected into controllers. ```typescript import { Injectable } from '@nestjs/common'; @Injectable() export class AdminService { getAdminData(): string { return 'Admin data from service'; } } ``` -------------------------------- ### Admin Service Example Source: https://github.com/taozhi1010/nest-admin/blob/master/admin/public/html/ie.html A basic implementation of an AdminService in NestJS, responsible for the core business logic of the admin module. This service would typically be injected into controllers. ```typescript import { Injectable } from '@nestjs/common'; @Injectable() export class AdminService { getAdminData(): string { return 'Admin data from service'; } } ```