Skip to content

Latest commit

 

History

History
68 lines (46 loc) · 1.27 KB

File metadata and controls

68 lines (46 loc) · 1.27 KB

TypeScript Express MySQL API Template

This is a template for creating a REST API using TypeScript, Express, and MySQL.

Features

  • TypeScript for type safety and modern JavaScript features
  • Express for building the API
  • MySQL for the database
  • Environment variables for configuration
  • Nodemon for development with automatic restarts

Getting Started

Prerequisites

  • Node.js
  • MySQL

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/your-repo-name.git
    cd your-repo-name
  2. Install dependencies:

    npm install
  3. Create a .env file based on .env.example and update the values as needed:

    cp .env.example .env
  4. Set up your MySQL database and update the .env file with your database credentials.

Running the Application

  • For development:

    npm run dev
  • For production:

    npm start

API Endpoints

  • GET /welcome: Get all users.
  • GET /welcome/:id: Get a user by ID.
  • POST /welcome: Add a new user.
  • DELETE /welcome/:id: Delete a user by ID.

Project Configuration

  • nodemon.json: Configuration for Nodemon.
  • tsconfig.json: TypeScript configuration.