NodeJS backend 연습 with express

repo: https://github.com/spyrr/express-backend-ex

 

spyrr/express-backend-ex

Backend development and some test examples using nodeJS - spyrr/express-backend-ex

github.com

 

사용 패키지

- cors, express, mongoose, morgan, nanoid, swagger-jsdoc, swagger-ui-express

- for testing: jest, lodash, supertest

프로그램 구성

다른 블로그에서 흔히 볼 수 있는 Books 입출력 예제 (mongodb 사용)

테스트 해보려 했던 것

지금이야... 기본적인 Backend 개발 로직 수준이지만, 차차 개선해 나가면서, 보안설정, exploit 테스트 등 여러 가지를 공부해보려 함.

 

아래 명령으로 실행:

 

$ git clone https://github.com/spyrr/express-backend-ex.git
$ cd express-backend-ex
$ yarn install
$ yarn dev

 

http://localhost:18888/api-docs/ 로 접속하면 swagger-ui 화면으로 접속 가능하며, 각 REST API를 테스트 해볼 수 있음

* 단, MongoDB는 별도 설치 필요

 

http://localhost:18888/api-docs/ 화면
jest에서 mongoose error 못잡았음...-_-; (명령: yarn test)

.... 위에.. 녀석은 결국 못잡고... 그냥, detectOpenHandles 옵션을 제거함... -_-

beforeAll과 afterAll도 써보고... Timeout도 써보고... 했지만, db에 대한 disconnection이 실행되서, connection 수가 0이 되어도, 위 메시지는 나타남... -_-;;;

detectOpenHandles 옵션 제거 후

다음에 할 내용

  • jest 로 테스트 실행 시, mongoose 쪽 에러 뜨는것을 잡아야... -_-
  • async 로직으로 변경
  • typescript로 전환
  • static analysis tool 추가
  • production build 추가 및 webpack, uglify 사용 테스트
  • CSRF token 사용을 위해, csurf를 사용하면 swagger-express에서 에러나서... 이것도 잡아야....
  • dotenv 및 vault 연동 테스트
  • devops 환경 구성 및 auto deployment / ochestration 테스트
  • 등등등등.... -_-
Comment