Nodejs Spring MVC -- 직접 디버그 ts 코드 지원

최근 에는 한가 하고 기발 한 생각 이 들 었 고 연습 도 하 는 김 에 태동 했다. type: script 의 decorator 로 Nodejs SpringMVC 를 쓸 수 있 는 지, 그리고 이 프로젝트 가 생 겼 다.이 항목 지원:
주입 컨트롤 러, 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 를 환영 합 니 다. 괜 찮 으 시다 면 스타 도 주세요.

좋은 웹페이지 즐겨찾기