[TypeScript] API 서버 템플릿

natae·2022년 9월 15일
0

TypeScript

목록 보기
1/1

개요

  • 기존 node.js의 javascript와 문법 및 사용법이 얼마나 다른지, 간단한 API 서버를 구현하면서 학습

과정

TypeScript 설치

# npm 미리 설치 필요

# tsc(typescript compiler) 설치
# 이후 tsc 명령어 사용 가능
$ npm install -g typescript

# tsconfig.json 파일 생성
$ tsc --init

$ npm install @types/node @types/express 

# 개발환경에만 필요한 것들
# nodemon: 실행중 소스 변경시 반영
# ts-node: tsc를 거치지 않고 ts 실행 가능
$ npm install -D nodemon ts-node

# 웹서버는 express 사용
$ npm install express

# DB는 async, await를 지원하는 mysql2 사용
$ npm install mysql2

코드 및 실행

https://github.com/natae/TypeScript_APIServer 참고

결론

  • golang 웹서버와 유사한 느낌을 받음

참고문헌

profile
서버 프로그래머

0개의 댓글