1. 添加.gitignore文件, 防止将过多的不必要的文件发送到服务器端: https://github.com/nestjs/typescript-starter/blob/master/.gitignore
2. 本地使用命令, 将代码发送到远程的master分支:
2.1. git add .
2.2. git commit -m "首次提交"
2.3. git remote add origin https://github.com/huangzhehao97/hzh-nestjs.git
2.4. git push -u origin master
3. 创建preview分支, 并将代码推送到preview方便后续的代码管理:
3.1. git checkout -b preview
3.2. git push origin preview
import { Controller, Get } from ‘@nestjs/common‘;
import { AppService } from ‘./app.service‘;
// 控制器装饰器
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
// Get装饰器
// 定义了一个get请求要执行的操作
@Get()
getHello(): string {
// 调用appService定义的getHello()方法
// Get请求"/"的反馈
return this.appService.getHello();
}
}
import { Injectable } from ‘@nestjs/common‘;
@Injectable()
export class AppService {
// 返回字符串类型
getHello(): string {
return ‘Hello World! 黄浙浩‘;
}
}
1. https://github.com/ninghao/ninghao-nestjs-s2-starter
1. npm install @nestjs/cli --global
2. 在项目的目录下创建一个服务nest1: nest generate app nest-1
3. 启动root应用: npm run start --watch原文:https://www.cnblogs.com/huangZ-H/p/12888209.html