logo
0
0
Login
docs: add README.en.md

Node.js Koa with Docker Compose (MySQL + Redis) for Remote Development

badge

This project uses Docker Compose to start MySQL and Redis services in a remote development environment, with Koa providing API services.

Quick Start

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.

  1. Install dependencies
npm install
  1. Start development

Supports command line execution:

npm run dev

Alternatively, you can debug in VSCode:

  • Click the "Run and Debug" icon in the activity bar on the left side of VSCode
  • Select "Debug Koa Application" from the run and debug drop-down list
  • Click the green run button (or press F5 directly)
  • View configuration
  1. Access API
curl http://localhost:3000 curl http://localhost:3000/users curl http://localhost:3000/visits

Project Structure

. ├── .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 file
  • Dockerfile: Docker configuration for Node.js application
  • .env.example: Environment variables example file
  • src/index.js: Main application file
  • mysql-init/init.sql: MySQL initialization script

API Endpoints

  • GET /: Welcome message
  • GET /users: Get user list (from MySQL)
  • GET /visits: Get and increment visit count (using Redis)
  • GET /init-db: Initialize database (execute SQL script)

Remote Development Configuration

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

LICENSE

MIT License