tankit
v1.0.9
Published
A script that will boot strap a node.ts Prisma MySql Api.
Downloads
10
Maintainers
Readme
Node.js + Prisma + MySQL Project Setup Script
Getting Started
After installing Tankit, you can easily initialize a new project with all the necessary configurations for Node.js, Prisma, and MySQL, including TypeScript, Prettier, and ESLint setups.
Prerequisites
Ensure you have Node.js, jq, Homebrew (for macOS), pnpm, and MySQL server installed on your machine.
Initialize a New Project
Run the following command in your terminal:
npx tankit-init
This script is a bash script used to automatically generate a new project using Node.js, Prisma ORM, and MySQL database. The script includes necessary configurations for TypeScript, Prettier, and ESLint. It also generates a basic user authentication mechanism with hashed passwords. This makes it easier to get started, and you can change to RDS / Plant Scale later
The script does the following in order:
- Prompts the user for project name and path.
- Checks for the presence of
jq
, a command-line JSON processor. If not present, the script offers to install it. - Checks for the directory where the project should be created. If the user does not provide one, the script uses the current directory.
- Prompts the user for MySQL credentials and database name. If not provided, the script uses default values.
- Creates a new Node.js project using
pnpm init
. - Installs required project dependencies and devDependencies, including Express, jsonwebtoken, Prisma, TypeScript, and more.
- Initializes Prisma with MySQL as the data source provider.
- Writes the database connection URL to a
.env
file. - Adds a
User
model to Prisma's schema file. - Installs and configures ESLint and Prettier for code formatting and linting.
- Configures TypeScript for the project.
- Generates Prisma client using
npx prisma migrate dev --name init
. - Creates the necessary directory structure for the project.
- Adds middleware for a single Prisma instance, password hashing, and authentication.
- Creates a user router for user-related routes.
The script also has necessary error checks in place to ensure that operations are successful before proceeding to the next step.
Prerequisites
The script requires the following installed on your machine:
- Node.js and npm
- jq
- Homebrew
- pnpm
- MySQL server
Usage
- Download or clone the bash script to your local machine.
- Run the script using the command
bash init_project.sh
.
The script will guide you through the rest of the process via prompts.
Note
This script assumes you are using macOS or a Linux-based operating system. For other operating systems, you may need to modify the script to match your environment.
Caution
The script will install packages globally on your machine if they are not found, including jq
and Homebrew
. Make sure you are comfortable with this before running the script.
Contribution
Contributions are always welcome! Please submit a PR if you have any improvements or feature additions.