The scripts/setup.sh script provides an automated way to set up your project from scratch.
📖 Setup Prerequisites - Complete prerequisites checklist and documentation links
Here's what happens when you run the setup script:
-
Pick Your Setup Style
- You'll choose between a quick boilerplate setup or a custom schema setup (where you add your own entities).
-
Name Your Project
- Enter your new project name (in kebab-case, like
my-cool-app). The script will handle renaming everything for you.
- Enter your new project name (in kebab-case, like
-
Environment Setup
- If you don't already have a
.envfile, the script will create one for you from theenv-example-relational.
- If you don't already have a
-
Install & Build
- All dependencies are installed, and the project is built so you're ready to go.
-
Migration from SQL Script (if you have one)
- If you’ve prepared a SQL script, the script will generate a migration from it automatically. Make sure to add your custom sql script to
.hygen/generate-migration/sql-script.sql
- If you’ve prepared a SQL script, the script will generate a migration from it automatically. Make sure to add your custom sql script to
-
Review Time (Custom schema only)
- If you chose custom schema, you'll get a chance to review your entities and migration files before moving forward. You can pause here if you want to double-check anything.
-
Run Migrations
- The database schema is set up for you.
-
Seed the Database
- Initial data is loaded in so you can start testing right away.
-
Generate Entities (Custom schema only)
- Your custom entities are generated from your schema.
-
Build Again
- The project is rebuilt to include any new changes.
-
Start the Server
- Your app launches and is ready for development!
The script will ask you:
- Project Name: Enter your project name in kebab-case (e.g.,
my-awesome-project) - Setup Type: Choose between:
- Boilerplate setup (skip entity generation): Get the base boilerplate application running
- Custom schema setup (generate entities from schema): Add your own entities and schema
You need to prepare these files before running the script:
- Custom Migration File: Add your custom SQL schema to the
.hygen/generate-migration/sql-script.sqlfile - Entity Schema JSON: Create
.hygen-entities-generator/entities-generator.json- Sample:
.hygen-sample-files/sample-entities-generator.json
- Sample:
-
Run the setup script:
npm run setup
-
Database Connection Error
- Ensure PostgreSQL is running:
docker compose up -d postgres - Verify database credentials in
env-example-relational - Check if database exists
- Ensure PostgreSQL is running:
-
Migration Errors
- Ensure base schema migration exists.
- Ensure don't repeat any action in your custom migration file that already done in base schema migration file
- Check for syntax errors in custom migration files
-
Entity Generation Errors
- Verify JSON schema format in
entities-generator.json - Check sample files for reference
- Verify JSON schema format in
After successful completion, you'll have:
- API Server: http://localhost:3000
- Swagger Documentation: http://localhost:3000/docs
- Database Admin: http://localhost:8080
A fully functional NestJS API ready for development and testing!
A default user is created in the database with the following credentials:
- Email:
admin@example.com - Password:
secret
You can test the project by logging in with these credentials.
Previous: Project Rename
Next: Architecture