This project uses Docker Compose to start MySQL and Redis services in a remote development environment, with Koa providing API services.
Click the Fork button in the upper right corner to fork the project to your own repository. Then click the Cloud Native Development button to start remote development.
npm install
Supports command line execution:
npm run dev
Alternatively, you can debug in VSCode:
curl http://localhost:3000 curl http://localhost:3000/users curl http://localhost:3000/visits
. ├── .ide │ └── Dockerfile ├── .vscode ├── docker-compose.yml ├── Dockerfile ├── .env.example ├── .gitignore ├── package.json ├── README.md ├── src │ └── app.js └── mysql-init └── init.sql
.ide/Dockerfile: Custom environment for remote development.vscode: VSCode configuration files (e.g., debug settings)docker-compose.yml: Docker Compose configuration fileDockerfile: Docker configuration for Node.js application.env.example: Environment variables example filesrc/index.js: Main application filemysql-init/init.sql: MySQL initialization scriptGET /: Welcome messageGET /users: Get user list (from MySQL)GET /visits: Get and increment visit count (using Redis)GET /init-db: Initialize database (execute SQL script)Configuration file is located at .cnb.yml, using CNB Cloud Native Development for remote development.
$:
# vscode event: specifically for starting remote development from the page
vscode:
- docker:
build: .ide/Dockerfile
services:
- vscode
- docker
stages:
# Starts MySQL, Redis and other services
- name: start docker compose
script: docker compose up -d