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 MongoDB database. The project includes necessary configurations for development, including a .gitignore
file, vercel.json
, and a basic docker-compose.yml
for MongoDB.
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 MongoDB 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 MongoDB.
- Create initial files such as
index.ts
for a basic Express server,.env
for environment variables, and.gitignore
to exclude node modules and other non-essential files. - Add a
README.md
file to your project directory with basic project information and setup instructions. - Create a
vercel.json
for deploying with Vercel if needed. - Set up a
docker-compose.yml
file to run a MongoDB database locally in a Docker container. This will use a simple username and password for authentication DO NOT USE IN PRODUCTION. - Create a
tools
directory with powershell scripts to start the server and MongoDB container and to wipe the database.
After setup:
- Run
docker-compose up -d
to start your MongoDB database. - Navigate to your project directory and run
npm install
to install all dependencies. - Use
npm start
to run your Express server.
To stop and remove the MongoDB container, you can use:
docker-compose down