This is a node.js basic API project using typescript.
Initialize a Node.js project within the project directory by creating a package.json file with default settings:
npm init -y
Your Node.js project requires a couple of dependencies to create a secure Express server with TypeScript. Install them like so:
npm i express body-parser ts-node typescript
npm i dotenv cors helmet
To use TypeScript effectively, you need to install type definitions for the packages you installed previously:
npm i -D @types/node @types/express @types/dotenv @types/cors @types/helmet
npx tsc --init
touch .env
Populate the .env hidden file with the following variable that defines the port your server can use to listen for requests:
PORT=2023
mkdir src
Under this src directory, create a file named index.ts to serve as the entry point of the application:
touch src/index.ts