{"id":30446985,"url":"https://github.com/tencentedgeone/mysql-template","last_synced_at":"2025-08-23T11:21:12.874Z","repository":{"id":311134717,"uuid":"1042444952","full_name":"TencentEdgeOne/mysql-template","owner":"TencentEdgeOne","description":"A full-stack application template based on **EdgeOne Pages** and **Next.js**, supporting MySQL database connections, allowing you to deploy production-level applications without managing servers.","archived":false,"fork":false,"pushed_at":"2025-08-22T09:10:55.000Z","size":83,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-22T11:29:13.730Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TencentEdgeOne.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-22T03:11:54.000Z","updated_at":"2025-08-22T09:10:58.000Z","dependencies_parsed_at":"2025-08-22T11:30:11.396Z","dependency_job_id":null,"html_url":"https://github.com/TencentEdgeOne/mysql-template","commit_stats":null,"previous_names":["tencentedgeone/mysql-template"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/TencentEdgeOne/mysql-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TencentEdgeOne%2Fmysql-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TencentEdgeOne%2Fmysql-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TencentEdgeOne%2Fmysql-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TencentEdgeOne%2Fmysql-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TencentEdgeOne","download_url":"https://codeload.github.com/TencentEdgeOne/mysql-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TencentEdgeOne%2Fmysql-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271746793,"owners_count":24813586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-23T11:21:07.598Z","updated_at":"2025-08-23T11:21:12.866Z","avatar_url":"https://github.com/TencentEdgeOne.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EdgeOne Pages MySQL Template\n\nA full-stack application template based on **EdgeOne Pages** and **Next.js**, supporting MySQL database connections, allowing you to deploy production-level applications without managing servers.\n\n## ✨ Features\n\n- 🚀 **Serverless Architecture** - Based on EdgeOne Pages Node Functions, no server management required\n- 🗄️ **MySQL Integration** - Built-in database connection pool and query executor\n- ⚡ **Modern Frontend** - Next.js 15 + React 19 + TypeScript\n- 🎨 **Beautiful UI** - Tailwind CSS 4 + Responsive Design\n- 🔧 **Out-of-the-Box** - Preconfigured development environment and build process\n- 📱 **Mobile-First** - Fully responsive design, supporting all devices\n\n## 🛠️ Tech Stack\n\n### Frontend\n- **Next.js 15.4.6** - React full-stack framework\n- **React 19.1.0** - User interface library\n- **TypeScript 5** - Type-safe JavaScript\n- **Tailwind CSS 4** - Utility-first CSS framework\n\n### Backend\n- **EdgeOne Pages** - Edge computing platform\n- **Node Functions** - Serverless function runtime\n- **MySQL2** - MySQL database driver\n\n### Development Tools\n- **ESLint** - Code quality checker\n- **PostCSS** - CSS postprocessor\n- **Turbopack** - Fast build tool\n\n## 🚀 Quick Start\n\n### Environment Requirements\n\n- Node.js 18.0 or higher\n- MySQL 5.7 or higher\n- EdgeOne Pages account\n\n### Install Dependencies\n\n```bash\n# Clone the project\ngit clone \u003cyour-repo-url\u003e\ncd mysql-template\n\n# Install dependencies\nnpm install\n```\n\n### Environment Configuration\n\nCreate a `.env.local` file and configure the database connection:\n\n```bash\n# Database configuration\nDB_HOST=your-mysql-host\nDB_PORT=3306\nDB_USER=your-username\nDB_PASSWORD=your-password\nDB_NAME=your-database-name\n```\n\n### Local Development\n\n```bash\n# Start the development server\nedgeone pages dev\n\n# Access http://localhost:8088\n```\n\n### Build and Deployment\n\n```bash\n# Build the production version\nedgeone pages build\n```\n\n## 📚 API Documentation\n\n### Database Query API\n\n**Endpoint**: `/db`  \n**Method**: `GET`  \n**Function**: Executes MySQL query and returns the result\n\n**Response Format**:\n```json\n{\n  \"success\": true,\n  \"data\": [...],\n  \"error\": null,\n  \"thisis\": \"get\"\n}\n```\n\n**Example Request**:\n```bash\ncurl -X GET https://your-domain.com/db\n```\n\n### Custom Query\n\nModify the SQL statement in the `node-functions/db.js` file:\n\n```javascript\n// Modify the query logic\nconst result = await executeQuery('SELECT * FROM your_table LIMIT 100');\n```\n\n## 🗄️ Database Configuration\n\n### MySQL Connection Configuration\n\nThe project uses a connection pool to manage database connections, supporting the following configurations:\n\n```javascript\nconst dbConfig = {\n  host: process.env.DB_HOST,\n  port: process.env.DB_PORT || 3306,\n  user: process.env.DB_USER,\n  password: process.env.DB_PASSWORD,\n  database: process.env.DB_NAME,\n  charset: 'utf8mb4',\n  timezone: '+08:00',\n  connectionLimit: 10,\n  acquireTimeout: 60000,\n  timeout: 60000,\n  reconnect: true\n};\n```\n\n### Database Table Structure\n\nEnsure your MySQL database has the corresponding table structure. Example:\n\n```sql\n\n```\n\n## 🏗️ Project Structure\n\n```\nmysql-template/\n├── src/                    # Source code directory\n│   ├── app/               # Next.js App Router\n│   │   ├── layout.tsx     # Root layout component\n│   │   ├── page.tsx       # Home page component\n│   │   └── globals.css    # Global styles\n│   ├── components/        # React components\n│   │   └── ui/           # UI component library\n│   └── lib/              # Utility functions\n├── node-functions/        # EdgeOne Pages functions\n│   └── db.js            # Database operation function\n├── public/               # Static resources\n├── package.json          # Project configuration\n├── next.config.ts        # Next.js configuration\n├── tailwind.config.js    # Tailwind CSS configuration\n└── tsconfig.json         # TypeScript configuration\n```\n\n## 🔧 Development Guide\n\n### Adding a New API Endpoint\n\nCreate a new `.js` file in the `node-functions/` directory:\n\n```javascript\nexport const onRequestGet = async (context) =\u003e {\n  // Handle GET request\n  return new Response(JSON.stringify({ message: \"Hello World\" }), {\n    headers: { 'Content-Type': 'application/json' }\n  });\n};\n\nexport const onRequestPost = async (context) =\u003e {\n  // Handle POST request\n  const body = await context.request.json();\n  return new Response(JSON.stringify({ received: body }), {\n    headers: { 'Content-Type': 'application/json' }\n  });\n};\n```\n\n### Customizing Styles\n\nThe project uses Tailwind CSS 4, and you can add custom styles in `src/app/globals.css`:\n\n```css\n@tailwind base;\n@tailwind components;\n@tailwind utilities;\n\n@layer components {\n  .custom-button {\n    @apply bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded;\n  }\n}\n```\n\n\n## 🐛 Troubleshooting\n\n### Common Issues\n\n**Database Connection Failure**\n- Check environment variable configurations\n- Confirm MySQL service status\n- Verify network connection and firewall settings\n\n**Build Error**\n- Clean up `node_modules` and `.next` directories\n- Reinstall dependencies: `npm install`\n- Check TypeScript type errors\n\n**API Call Failure**\n- Check EdgeOne Pages function deployment status\n- View function log output\n- Confirm database table structure\n\n## 📄 License\n\nThis project uses the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Deployment\n[![Deploy with EdgeOne Pages](https://cdnstatic.tencentcs.com/edgeone/pages/deploy.svg)](https://edgeone.ai/pages/new?from=github\u0026template=express-template)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftencentedgeone%2Fmysql-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftencentedgeone%2Fmysql-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftencentedgeone%2Fmysql-template/lists"}