This README outlines the usage of a PowerShell script designed to automate the setup of a Node.js project with Express, TypeScript, Prisma, dotenv, and a Dockerized MySQL database. The project includes necessary configurations for development, including a .gitignore file, vercel.json, and a basic docker-compose.yml for MySQL.
Before running the script, make sure you have the following installed on your system:
- Node.js (v14 or higher)
- npm (comes with Node.js)
- Docker Desktop (for MySQL containerization)
- PowerShell
Run the Script: Execute the script by typing ./CreateExpressApp.ps1 -projectName <project-name> in your terminal. Replace <project-name> with the name of your project.
Upon execution, the script will:
- Create a new directory for your Node.js project.
- Initialize a new npm project and install necessary dependencies, including Express, dotenv, and Prisma.
- Set up TypeScript for development.
- Configure Prisma to connect to MySQL.
- Create initial files such as
index.tsfor a basic Express server,.envfor environment variables, and.gitignoreto exclude node modules and other non-essential files. - Add a
README.mdfile to your project directory with basic project information and setup instructions. - Create a
vercel.jsonfor deploying with Vercel if needed. - Set up a
docker-compose.ymlfile to run a MySQL database locally in a Docker container. This will use a simple username and password for authentication DO NOT USE IN PRODUCTION. - Create a
toolsdirectory with powershell scripts to start the server and MySQL container and to wipe the database.
After setup:
- Run
docker-compose up -dto start your MySQL database. - Navigate to your project directory and run
npm installto install all dependencies. - Use
npm startto run your Express server.
To stop and remove the MySQL container, you can use:
docker-compose down