Install dependencies & entry file

Setting Up Your TypeScript Project with Express

I skipped a few steps initially to avoid boring you with the npm installation part. Here are the steps I took:

  1. Dependencies: Added the necessary dependencies and devDependencies required for the project.
  2. Package Configuration:

    • name: Project name
    • version: Project version
    • description: Brief project description
    • main: Entry point for your application
    • scripts section: Added scripts
    • license

You will notice the script section was updated. I will explain it later as we haven't discussed these files yet.

New Project Structure and Configuration Files

After setting up, you will see a few changes:

  • package-lock.json: Logs the dependencies
  • node_modules: Stores all the packages
  • tsconfig.json: Sets up compiler properties for TypeScript

This configuration is fairly standard and is what you get with the default tsconfig setup.

Creating the Source Folder and Index File

We will now create the source folder and a new file called index.ts.

Setting up the Express Application

As previously discussed, we will create an Express app for our REST application and add an Express router to manage different routes. I will cover the router in detail in the next lesson.

For now, we can use GitHub Copilot to generate a basic application:

Running the Application

Go back to the package.json file, locate the start command, and execute it:

Run the script:

If everything is set up correctly, you should see the message:

Your server is now up and running!