Compile and Hot-Reload for Development
masterStart the development server with hot-reloading enabled.
npm run devrepository·master·Indexed 27 days ago
https://github.com/techschool/simplebankA banking application featuring a Vue 3 frontend powered by Vite and a backend consisting of a gRPC server, a gRPC-Gateway HTTP server, and a standalone Gin server. The system includes a Redis-based task processor for background workers, a PostgreSQL database with migrations, and support for Paseto token authentication.
Start the development server with hot-reloading enabled.
npm run devExecute the project's unit tests using Vitest.
npm run test:unitRun the production build process. This includes type-checking using vue-tsc (instead of tsc) to ensure .vue file type support, followed by compilation and minification.
npm run buildInstall the project dependencies using npm.
npm installRun the ESLint linter to check for code quality and style issues.
npm run lintThe main function serves as the entrypoint for the SimpleBank application. When executed, it performs the following sequence:
util.LoadConfig.pgxpool.runDBMigration.db.NewStore.errgroup:The application handles graceful shutdowns for all services upon receiving os.Interrupt, syscall.SIGTERM, or syscall.SIGINT.
The api service can be configured using environment variables to define database connectivity and Redis addressing. The service builds from the local Dockerfile and exposes ports 8080 and 9090.
api:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
- "9090:9090"
environment:
- DB_SOURCE=postgresql://root:secret@postgres:5432/simple_bank?sslmode=disable
- REDIS_ADDRESS=redis:6379The postgres service uses the postgres:14-alpine image. You can configure the database credentials and name using the following environment variables:
POSTGRES_USER: The database user (default: root)POSTGRES_PASSWORD: The database password (default: secret)POSTGRES_DB: The database name (default: simple_bank)Data is persisted using the data-volume volume.
postgres:
image: postgres:14-alpine
environment:
- POSTGRES_USER=root
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=simple_bank
ports:
- "5432:5432"
volumes:
- data-volume:/var/lib/postgresql/dataThe redis service uses the redis:7-alpine image and is available to the api service at the hostname redis on port 6379.
redis:
image: redis:7-alpineThe runTaskProcessor function initializes and starts the background worker system. It uses a Redis-based task distributor and a Gmail sender for email tasks.
Parameters:
ctx: Context for lifecycle management.waitGroup: An errgroup.Group to manage the processor's lifecycle.config: The application configuration (util.Config).redisOpt: Redis client options (asynq.RedisClientOpt).store: The database store (db.Store).When the provided ctx is cancelled, the function triggers a graceful shutdown of the taskProcessor.
func runTaskProcessor(
ctx context.Context,
waitGroup *errgroup.Group,
config util.Config,
redisOpt asynq.RedisClientOpt,
store db.Store,
)