We are using jsonplaceholder
API to act as a third-party API for our app.
Run following commands for initialization
npm init
git init
tsc init
npm i express
npm i axios
For dev dependencies install following packages
npm i typescript -D
npm i @types/node -D
npm i @types/express -D
npm i ts-node-dev -D
Create src
folder. The src
folder will hold up the project TS files. The structure for src
will be as follows:
src/
|-- models/
|-- post.ts
|-- routes/
|-- posts.ts
server.ts
"scripts": {
"start": "node dist/server",
"build": "tsc -p .",
"watch": "ts-node-dev --respawn --transpile-only ./src/server.ts"
},
npm run build
npm start
// or
npm run watch