Nodejs Spring MVC -- 직접 디버그 ts 코드 지원
주입 컨트롤 러, Service 주입 GET / POST / PUT / DELETE / PATCH 등 rest 방법 으로 rest api 의 인 자 를 분석 합 니 다. 예 를 들 어 RequestParam 업로드 파일 은 Multer 가 vscode 에서 직접 debug typescript 을 지원 하 는 코드 를 지원 합 니 다.
debug typescript 코드 를 배우 고 싶 은 학생 은 주의 하 셔 도 됩 니 다. 정말 좋 습 니 다.readMe 부분 에 직접 올 리 기:
Installation
npm i easy-node-ioc --save
Quick Start
Check out the quick start example in
test
. Usage
1.Create a Controller
import { Controller} from 'easy-node-ioc';
@Controller('/test')
class TestControl {
...
}
2.Create a Service
import { Service } from 'easy-node-ioc';
@Service('')
class TestService {
...
}
3.Inject Service
import { Autowired,Controller } from 'easy-node-ioc';
@Controller('/test')
class TestControl {
@Autowired
testService: TestService;
...
}
4.Define Rest API:GET,POST,PUT,DELETE,PATCH
import { Autowired,Controller,GET,RequestParam } from 'easy-node-ioc';
@Controller('/test')
class TestControl {
@Autowired
testService: TestService;
@Get('/index')
index(@RequestParam('age') age: number, req: Request, res: Response) {
console.log('index method');
this.dbService.queryDb();
res.status(200).send(this.testService.queryDb());
}
...
}
4.Define Start App
import { Bootstrap, ComponentScan } from "../";
@ComponentScan(join(__dirname, "./Controller.ts"))
@Bootstrap
class App {
constructor() {}
app = express();
main() {
const server = http.createServer(this.app);
server.listen(9001, function() {
console.log("Example app listening at http://%s:%s");
});
}
}
How to debug
if you use vscode , just follow
.vscode/launch.json
, select Launch Program
. if you see Example app has started.
in the console , then means test case start successfully . Try to call http://localhost:9001/api/test/index
. gitHub 주소:https://github.com/chenkang08...
설명: 이 프로젝트 도 갑 작 스 러 운 기상 으로 인해 문제 가 있 을 수 있 습 니 다.그러나 현재 나 는 이미 이 가방 을 사용 하여 우리 회사 내부 의 node 배경 프로젝트 를 다시 썼 고 현재 모든 것 이 잘 운영 되 고 있다.그리고 issues 를 환영 합 니 다. 괜 찮 으 시다 면 스타 도 주세요.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Thymeleaf 의 일반 양식 제출 과 AJAX 제출텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.