Express TypeScript API

by mhofwell

170 downloads
Not rated
GitHub

Description

# Express TypeScript API A blank Express server setup with TypeScript support. ## Project Structure ``` express-typescript-api/ ├── src/ # Source files │ ├── config/ # Configuration files │ ├── routes/ # API routes │ └── server.ts # Express application setup ├── dist/ # Compiled…

About

# Express TypeScript API A blank Express server setup with TypeScript support. ## Project Structure ``` express-typescript-api/ ├── src/ # Source files │ ├── config/ # Configuration files │ ├── routes/ # API routes │ └── server.ts # Express application setup ├── dist/ # Compiled JavaScript files ├── .gitignore # Git…

Details

Author
mhofwell
Downloads
170
Categories
Developer Tools

- Blank Express setup with TypeScript support
- Development server with hot‑reloading (npm run dev)
- Production build pipeline (npm run build + npm start)
- Predefined project structure (src/, dist/, config, routes)
- Two built‑in endpoints: GET / and GET /health
- Environment variable configuration via .env file

Clone the repository, install dependencies with npm install, then run npm run dev for development with hot‑reloading at http://localhost:3000. For production, compile TypeScript with npm run build and start the compiled JavaScript with npm start. Configure environment variables like PORT and NODE_ENV in a .env file.

Express TypeScript API

A blank Express server setup with TypeScript support.

Project Structure

express-typescript-api/
├── src/                  # Source files
│   ├── config/           # Configuration files
│   ├── routes/           # API routes
│   └── server.ts         # Express application setup
├── dist/                 # Compiled JavaScript files
├── .gitignore            # Git ignore file
├── package.json          # Project metadata and dependencies
├── tsconfig.json         # TypeScript configuration
└── README.md             # Project documentation

Prerequisites

- Node.js (v14.x or higher recommended)
- npm (v6.x or higher)

Installation

1. Clone the repository:

    git clone <repository-url>
    cd express-typescript-api
    

2. Install dependencies:

    npm install

Development

To start the development server with hot-reloading:

npm run dev

This will start the server at http://localhost:3000

Building for Production

To compile the TypeScript code to JavaScript:

npm run build

This will create the compiled JavaScript files in the dist directory.

Running in Production

To run the compiled JavaScript in production:

npm start

Available API Endpoints

- GET /: Returns a welcome message
- GET /health: Health check endpoint

Environment Variables

Create a .env file in the root directory with the following variables:

NODE_ENV=development
PORT=3000

Adding New Routes

1. Create a new route file in the src/routes directory
2. Import and use the route in src/server.ts

License

ISC

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.