This package.json
file defines a starting point for building an Express API using TypeScript. Here’s a breakdown of its components:
-
Project Info:
- Name:
vinesh-express-api
- Version:
0.0.1
- Description: "Starting point for building an Express API with TypeScript."
- Main: Points to the entry file
src/index.ts
.
- Name:
-
Scripts:
"start"
: Runs the API usingts-node
on port 3000."dev"
: Runs the API in development mode usingnodemon
to restart automatically on changes."build"
: Compiles the TypeScript code to JavaScript usingtsc
."start:dist"
: Runs the compiled JavaScript code from thedist
directory."lint"
: Runs ESLint with the--fix
option on thesrc
andtest
folders to automatically fix linting issues."test"
: Runs tests usingjest
."typecheck"
: Performs a type check without emitting any compiled files.
-
Dependencies:
- Express: The core web framework for building APIs.
- Axios: For making HTTP requests.
- bcrypt: For password hashing and comparison.
- cors: To enable cross-origin resource sharing.
- dotenv: For loading environment variables from
.env
files. - helmet: For security-related HTTP headers.
- jsonwebtoken: For generating and verifying JWT tokens.
- mongodb and mongoose: To work with MongoDB databases.
- morgan: For logging HTTP requests.
-
Dev Dependencies:
- TypeScript: The TypeScript language itself.
- ts-node: To run TypeScript files directly in Node.js without precompiling.
- nodemon: For automatically restarting the server during development.
- Jest and Supertest: For testing, including integration tests.
- ESLint: For linting the TypeScript code.
- Airbnb ESLint Configuration: Follows Airbnb’s style guide for TypeScript.
- Various @types packages: For TypeScript type definitions of the libraries (like Express, bcrypt, JWT, etc.).
This is a well-rounded setup for developing a secure, testable, and scalable API using Express and TypeScript. It includes robust linting, security, and testing mechanisms.