This repository contains a basic TypeScript Express application that utilizes Node.js for server-side functionality. It is configured with Nodemon for automatic server restarts during development and uses ts-node for TypeScript execution.
Before you begin, ensure you have the following installed on your machine:
- Node.js: Ensure that Node.js, preferably version 16 or higher, is installed on your system, as this project utilizes the latest versions of TypeScript and Nodemon.
- npm: npm is the package manager for Node.js and comes with the Node.js installation.
Clone the repository to your local machine:
git clone https://github.com/c99rahul/ts-node-express.git
Navigate to the project directory:
cd ts-node-express/
Install the project dependencies including TypeScript and Nodemon:
npm i
For development purposes, you can run the application using Nodemon to automatically restart the server when changes are detected. Execute the following command:
npm run dev
This will start the server at http://localhost:3000
by default. You can change the port in the src/index.ts
file or create an .env
file to manage the environt-specific variables separately.
For production, you can build the TypeScript files and then start the server. Run the following commands:
npm run build
npm start
The project structure is organized as follows:
src
: Contains TypeScript source filesindex.ts
: Configures and starts the Express application
dist
: Output directory created during build for compiled TypeScript filespackage.json
: Project configuration and dependenciestsconfig.json
: TypeScript configuration
You can customize the project configuration i nthe tsconfig.json
file and adjust the server settings in the src/index.ts
file.
This project is licensed under the MIT License - see the LICENSE file for details.