NOTE: Before using this template, you need to install
pnpm(only for development),dockeranddocker compose.
Create a new project based on this template using degit:
pnpx degit CitRUSprod/svelte-kit-website-starter my-website
cd my-website
pnpm iThe launch is done through docker compose, but with scripts scripts/dev and scripts/prod:
scripts/dev <docker compose command>
scripts/prod <docker compose command>Run the project by entering these commands and open http://localhost:6700 in your browser:
# Development
scripts/dev up -d
pnpm dev # or "cd apps/<app>" and "pnpm dev"
# Production
scripts/startscripts/dev up -d # Start
scripts/dev down # Stop
scripts/dev logs <app> # View app logs
scripts/dev exec <app> sh # Enter the app container
scripts/dev <docker compose command> # Any docker compose commandscripts/prod up -d # Start
scripts/prod down # Stop
scripts/prod logs <app> # View app logs
scripts/prod exec <app> sh # Enter the app container
scripts/prod <docker compose command> # Any docker compose command
# or shortcuts
scripts/start # Start
scripts/stop # Stop
scripts/restart # Restart- Enter this command and edit the
.envfile:
scripts/clone-env- Start required docker containers for development:
scripts/dev up -d- Install project dependencies:
pnpm i- Build packages:
pnpm build- Run database migrations:
pnpm --filter api prisma:migrations:run- Seed the database:
pnpm --filter api prisma:seeds:run- Start web and api in development mode:
pnpm dev- Enter this command and edit the
.envfile:
scripts/clone-env- Start required docker containers for production:
scripts/start- Seed the database:
scripts/prod exec api pnpm prisma:seeds:runAfter completing all steps, the application will be available at http://localhost:<WEBSITE_PORT> (default is http://localhost:6700).
apps- Applicationspackages- Local librariesconfigs- Configuration files (docker, nginx, etc.)scripts- Project management scripts (start, stop, restart, backup, etc.)storage- Storage directory for backups and other data that should not be in the repositorye2e-tests- E2E tests with Playwright
Commit with commitizen:
pnpm commitCheck types with tsc:
pnpm check-typesLint with linters:
pnpm lintFormat with formatters:
pnpm formatUnit test with vitest:
pnpm test:unitE2E test with playwright:
pnpm test:e2eValidate project (types + linting + unit tests):
pnpm validateAll environment variables are written to the .env file. If it doesn't exist, just enter this command:
scripts/clone-envThe project uses prisma to work with the database.
Migrations and seeds are located in apps/api/src/prisma in the migrations folder and seeds.ts file. To work with them, you need to go to the api app directory:
# Development
cd apps/api
# Production
scripts/prod exec api shThen you can enter any of the following commands:
pnpm prisma:migrations:create # Create migrations
pnpm prisma:migrations:run # Run migrations
pnpm prisma:migrations:reset # Reset migrations
pnpm prisma:seeds:run # Run default seeds
pnpm prisma:seeds:run --seed test-users # Run test users seedsBackups are placed in storage/backups folder.
For manual backup you can use this command:
scripts/create-backupFor automatic backups you can use these commands:
scripts/enable-automatic-backups # Enable automatic backups (using cron)
scripts/check-automatic-backups # Check if automatic backups are enabled
scripts/disable-automatic-backups # Disable automatic backupsThe schedule for automatic backups can be configured in .env file using BACKUPS_SCHEDULE variable in cron format.
Example: BACKUPS_SCHEDULE="0 3 * * *" for daily backup at 3 AM.
To restore a database from backup you can use this command:
scripts/restore-backup <YYYY-MM-DD_hh-mm-ss> # For example 2020-05-13_21-35-00Swagger UI is available at: http://localhost:6700/api/v1/swagger.
To enable Swagger UI, set the ENABLE_SWAGGER=true variable in your .env file.
Adminer is available at: http://localhost:6700/admin/adminer.
Login credentials: POSTGRES_USER, POSTGRES_PASSWORD and POSTGRES_DB from .env.
MinIO Console is available at: http://localhost:6700/admin/minio.
Login credentials: MINIO_USER and MINIO_PASSWORD from .env.