@lambertkeith/spec-go 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +163 -0
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.js +850 -0
  5. package/dist/index.js.map +1 -0
  6. package/package.json +46 -0
  7. package/templates/django/README.md +27 -0
  8. package/templates/django/_gitignore +20 -0
  9. package/templates/django/_template.json +14 -0
  10. package/templates/django/manage.py +22 -0
  11. package/templates/django/project_name/__init__.py +1 -0
  12. package/templates/django/project_name/asgi.py +11 -0
  13. package/templates/django/project_name/settings.py +75 -0
  14. package/templates/django/project_name/urls.py +16 -0
  15. package/templates/django/project_name/wsgi.py +11 -0
  16. package/templates/django/pyproject.toml +20 -0
  17. package/templates/empty/README.md +3 -0
  18. package/templates/empty/_gitignore +6 -0
  19. package/templates/empty/_template.json +6 -0
  20. package/templates/express-ts/README.md +27 -0
  21. package/templates/express-ts/_gitignore +7 -0
  22. package/templates/express-ts/_template.json +13 -0
  23. package/templates/express-ts/package.json +23 -0
  24. package/templates/express-ts/src/index.ts +17 -0
  25. package/templates/express-ts/src/middleware/error-handler.ts +14 -0
  26. package/templates/express-ts/src/routes/index.ts +11 -0
  27. package/templates/express-ts/tsconfig.json +17 -0
  28. package/templates/express-ts/tsup.config.ts +9 -0
  29. package/templates/fastapi/README.md +21 -0
  30. package/templates/fastapi/_gitignore +16 -0
  31. package/templates/fastapi/_template.json +14 -0
  32. package/templates/fastapi/pyproject.toml +21 -0
  33. package/templates/fastapi/src/project_name/__init__.py +1 -0
  34. package/templates/fastapi/src/project_name/main.py +20 -0
  35. package/templates/fastapi/src/project_name/routes/__init__.py +8 -0
  36. package/templates/flask/README.md +15 -0
  37. package/templates/flask/_gitignore +17 -0
  38. package/templates/flask/_template.json +14 -0
  39. package/templates/flask/pyproject.toml +19 -0
  40. package/templates/flask/src/project_name/__init__.py +1 -0
  41. package/templates/flask/src/project_name/app.py +15 -0
  42. package/templates/flask/src/project_name/routes/__init__.py +8 -0
  43. package/templates/fullstack-react-node/README.md +35 -0
  44. package/templates/fullstack-react-node/_gitignore +7 -0
  45. package/templates/fullstack-react-node/_template.json +14 -0
  46. package/templates/fullstack-react-node/backend/package.json +22 -0
  47. package/templates/fullstack-react-node/backend/src/index.ts +20 -0
  48. package/templates/fullstack-react-node/backend/tsconfig.json +17 -0
  49. package/templates/fullstack-react-node/backend/tsup.config.ts +9 -0
  50. package/templates/fullstack-react-node/frontend/index.html +12 -0
  51. package/templates/fullstack-react-node/frontend/package.json +22 -0
  52. package/templates/fullstack-react-node/frontend/src/App.css +16 -0
  53. package/templates/fullstack-react-node/frontend/src/App.tsx +22 -0
  54. package/templates/fullstack-react-node/frontend/src/main.tsx +9 -0
  55. package/templates/fullstack-react-node/frontend/tsconfig.json +20 -0
  56. package/templates/fullstack-react-node/frontend/vite.config.ts +14 -0
  57. package/templates/fullstack-react-node/package.json +10 -0
  58. package/templates/fullstack-react-node/pnpm-workspace.yaml +3 -0
  59. package/templates/fullstack-react-python/Makefile +35 -0
  60. package/templates/fullstack-react-python/README.md +43 -0
  61. package/templates/fullstack-react-python/_gitignore +18 -0
  62. package/templates/fullstack-react-python/_template.json +25 -0
  63. package/templates/fullstack-react-python/backend/pyproject.toml +21 -0
  64. package/templates/fullstack-react-python/backend/src/project_name/__init__.py +1 -0
  65. package/templates/fullstack-react-python/backend/src/project_name/main.py +29 -0
  66. package/templates/fullstack-react-python/backend/src/project_name/routes/__init__.py +8 -0
  67. package/templates/fullstack-react-python/frontend/index.html +12 -0
  68. package/templates/fullstack-react-python/frontend/package.json +22 -0
  69. package/templates/fullstack-react-python/frontend/src/App.css +16 -0
  70. package/templates/fullstack-react-python/frontend/src/App.tsx +22 -0
  71. package/templates/fullstack-react-python/frontend/src/main.tsx +9 -0
  72. package/templates/fullstack-react-python/frontend/tsconfig.json +20 -0
  73. package/templates/fullstack-react-python/frontend/vite.config.ts +14 -0
  74. package/templates/fullstack-vue-node/README.md +35 -0
  75. package/templates/fullstack-vue-node/_gitignore +7 -0
  76. package/templates/fullstack-vue-node/_template.json +14 -0
  77. package/templates/fullstack-vue-node/backend/package.json +22 -0
  78. package/templates/fullstack-vue-node/backend/src/index.ts +20 -0
  79. package/templates/fullstack-vue-node/backend/tsconfig.json +17 -0
  80. package/templates/fullstack-vue-node/backend/tsup.config.ts +9 -0
  81. package/templates/fullstack-vue-node/frontend/index.html +12 -0
  82. package/templates/fullstack-vue-node/frontend/package.json +20 -0
  83. package/templates/fullstack-vue-node/frontend/src/App.vue +41 -0
  84. package/templates/fullstack-vue-node/frontend/src/main.ts +4 -0
  85. package/templates/fullstack-vue-node/frontend/src/vite-env.d.ts +1 -0
  86. package/templates/fullstack-vue-node/frontend/tsconfig.json +20 -0
  87. package/templates/fullstack-vue-node/frontend/vite.config.ts +14 -0
  88. package/templates/fullstack-vue-node/package.json +10 -0
  89. package/templates/fullstack-vue-node/pnpm-workspace.yaml +3 -0
  90. package/templates/next-ts/README.md +26 -0
  91. package/templates/next-ts/_gitignore +34 -0
  92. package/templates/next-ts/_template.json +13 -0
  93. package/templates/next-ts/next.config.ts +7 -0
  94. package/templates/next-ts/package.json +22 -0
  95. package/templates/next-ts/src/app/globals.css +21 -0
  96. package/templates/next-ts/src/app/layout.tsx +19 -0
  97. package/templates/next-ts/src/app/page.tsx +10 -0
  98. package/templates/next-ts/tsconfig.json +27 -0
  99. package/templates/node-ts/README.md +21 -0
  100. package/templates/node-ts/_gitignore +7 -0
  101. package/templates/node-ts/_template.json +16 -0
  102. package/templates/node-ts/package.json +19 -0
  103. package/templates/node-ts/src/index.ts +1 -0
  104. package/templates/node-ts/tsconfig.json +17 -0
  105. package/templates/node-ts/tsup.config.ts +9 -0
  106. package/templates/python-uv/README.md +22 -0
  107. package/templates/python-uv/_gitignore +30 -0
  108. package/templates/python-uv/_template.json +14 -0
  109. package/templates/python-uv/pyproject.toml +20 -0
  110. package/templates/python-uv/src/project_name/__init__.py +10 -0
  111. package/templates/python-uv/src/project_name/__main__.py +4 -0
  112. package/templates/react-ts/_gitignore +6 -0
  113. package/templates/react-ts/_template.json +13 -0
  114. package/templates/react-ts/index.html +13 -0
  115. package/templates/react-ts/package.json +23 -0
  116. package/templates/react-ts/src/App.css +14 -0
  117. package/templates/react-ts/src/App.tsx +12 -0
  118. package/templates/react-ts/src/index.css +11 -0
  119. package/templates/react-ts/src/main.tsx +10 -0
  120. package/templates/react-ts/tsconfig.json +20 -0
  121. package/templates/react-ts/vite.config.ts +6 -0
  122. package/templates/springboot/.mvn/wrapper/maven-wrapper.properties +2 -0
  123. package/templates/springboot/README.md +27 -0
  124. package/templates/springboot/_gitignore +36 -0
  125. package/templates/springboot/_template.json +14 -0
  126. package/templates/springboot/mvnw +19 -0
  127. package/templates/springboot/mvnw.cmd +13 -0
  128. package/templates/springboot/pom.xml +46 -0
  129. package/templates/springboot/src/main/java/com/example/project_name/Application.java +12 -0
  130. package/templates/springboot/src/main/java/com/example/project_name/controller/HelloController.java +25 -0
  131. package/templates/springboot/src/main/resources/application.yml +6 -0
  132. package/templates/springboot/src/test/java/com/example/project_name/ApplicationTests.java +12 -0
  133. package/templates/template.config.json +102 -0
  134. package/templates/vue-ts/_gitignore +6 -0
  135. package/templates/vue-ts/_template.json +13 -0
  136. package/templates/vue-ts/index.html +13 -0
  137. package/templates/vue-ts/package.json +20 -0
  138. package/templates/vue-ts/src/App.vue +37 -0
  139. package/templates/vue-ts/src/main.ts +5 -0
  140. package/templates/vue-ts/src/style.css +11 -0
  141. package/templates/vue-ts/src/vite-env.d.ts +7 -0
  142. package/templates/vue-ts/tsconfig.json +20 -0
  143. package/templates/vue-ts/vite.config.ts +6 -0
@@ -0,0 +1,21 @@
1
+ [project]
2
+ name = "{{projectName}}"
3
+ version = "0.1.0"
4
+ description = "FastAPI project"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ dependencies = [
8
+ "fastapi>=0.115.0",
9
+ "uvicorn[standard]>=0.34.0",
10
+ ]
11
+
12
+ [build-system]
13
+ requires = ["hatchling"]
14
+ build-backend = "hatchling.build"
15
+
16
+ [tool.uv]
17
+ dev-dependencies = [
18
+ "pytest>=8.0.0",
19
+ "httpx>=0.27.0",
20
+ "ruff>=0.8.0",
21
+ ]
@@ -0,0 +1 @@
1
+ """{{projectName}} - FastAPI application"""
@@ -0,0 +1,20 @@
1
+ from fastapi import FastAPI
2
+ from .routes import router
3
+
4
+ app = FastAPI(
5
+ title="{{projectName}}",
6
+ description="FastAPI application",
7
+ version="0.1.0"
8
+ )
9
+
10
+ app.include_router(router, prefix="/api")
11
+
12
+
13
+ @app.get("/")
14
+ async def root():
15
+ return {"message": "Welcome to {{projectName}}"}
16
+
17
+
18
+ @app.get("/health")
19
+ async def health():
20
+ return {"status": "ok"}
@@ -0,0 +1,8 @@
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.get("/hello")
7
+ async def hello():
8
+ return {"message": "Hello, World!"}
@@ -0,0 +1,15 @@
1
+ # {{projectName}}
2
+
3
+ Flask 项目
4
+
5
+ ## 开发
6
+
7
+ ```bash
8
+ uv run flask --app src/{{projectName}}/app run --debug
9
+ ```
10
+
11
+ ## 测试
12
+
13
+ ```bash
14
+ uv run pytest
15
+ ```
@@ -0,0 +1,17 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ .Python
5
+ .venv/
6
+ venv/
7
+ env/
8
+ .env
9
+ .env.local
10
+ *.egg-info/
11
+ dist/
12
+ build/
13
+ .pytest_cache/
14
+ .ruff_cache/
15
+ .DS_Store
16
+ *.log
17
+ instance/
@@ -0,0 +1,14 @@
1
+ {
2
+ "description": "Flask 项目模板",
3
+ "packageManager": "uv",
4
+ "postInit": [
5
+ {
6
+ "command": "uv sync",
7
+ "description": "安装依赖"
8
+ }
9
+ ],
10
+ "fileRenames": {
11
+ "_gitignore": ".gitignore",
12
+ "project_name": "{{projectName}}"
13
+ }
14
+ }
@@ -0,0 +1,19 @@
1
+ [project]
2
+ name = "{{projectName}}"
3
+ version = "0.1.0"
4
+ description = "Flask project"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ dependencies = [
8
+ "flask>=3.0.0",
9
+ ]
10
+
11
+ [build-system]
12
+ requires = ["hatchling"]
13
+ build-backend = "hatchling.build"
14
+
15
+ [tool.uv]
16
+ dev-dependencies = [
17
+ "pytest>=8.0.0",
18
+ "ruff>=0.8.0",
19
+ ]
@@ -0,0 +1 @@
1
+ """{{projectName}} - Flask application"""
@@ -0,0 +1,15 @@
1
+ from flask import Flask
2
+ from .routes import bp
3
+
4
+ app = Flask(__name__)
5
+ app.register_blueprint(bp, url_prefix='/api')
6
+
7
+
8
+ @app.route('/')
9
+ def index():
10
+ return {'message': 'Welcome to {{projectName}}'}
11
+
12
+
13
+ @app.route('/health')
14
+ def health():
15
+ return {'status': 'ok'}
@@ -0,0 +1,8 @@
1
+ from flask import Blueprint
2
+
3
+ bp = Blueprint('api', __name__)
4
+
5
+
6
+ @bp.route('/hello')
7
+ def hello():
8
+ return {'message': 'Hello, World!'}
@@ -0,0 +1,35 @@
1
+ # {{projectName}}
2
+
3
+ React + Node.js 全栈项目 (pnpm workspace)
4
+
5
+ ## 项目结构
6
+
7
+ ```
8
+ {{projectName}}/
9
+ ├── frontend/ # React 前端 (Vite)
10
+ ├── backend/ # Express 后端
11
+ └── package.json # Workspace 根配置
12
+ ```
13
+
14
+ ## 开发
15
+
16
+ 同时启动前后端开发服务器:
17
+
18
+ ```bash
19
+ pnpm dev
20
+ ```
21
+
22
+ - 前端: http://localhost:5173
23
+ - 后端: http://localhost:3001
24
+
25
+ ## 构建
26
+
27
+ ```bash
28
+ pnpm build
29
+ ```
30
+
31
+ ## 测试
32
+
33
+ ```bash
34
+ pnpm test
35
+ ```
@@ -0,0 +1,7 @@
1
+ node_modules/
2
+ dist/
3
+ *.log
4
+ .DS_Store
5
+ .env
6
+ .env.local
7
+ coverage/
@@ -0,0 +1,14 @@
1
+ {
2
+ "description": "React + Node.js 全栈项目模板",
3
+ "packageManager": "pnpm",
4
+ "type": "workspace",
5
+ "postInit": [
6
+ {
7
+ "command": "pnpm install",
8
+ "description": "安装依赖"
9
+ }
10
+ ],
11
+ "fileRenames": {
12
+ "_gitignore": ".gitignore"
13
+ }
14
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "{{projectName}}-backend",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "tsx watch src/index.ts",
7
+ "build": "tsup",
8
+ "start": "node dist/index.js"
9
+ },
10
+ "dependencies": {
11
+ "cors": "^2.8.5",
12
+ "express": "^4.21.2"
13
+ },
14
+ "devDependencies": {
15
+ "@types/cors": "^2.8.17",
16
+ "@types/express": "^5.0.0",
17
+ "@types/node": "^22.10.7",
18
+ "tsup": "^8.3.5",
19
+ "tsx": "^4.19.2",
20
+ "typescript": "^5.7.3"
21
+ }
22
+ }
@@ -0,0 +1,20 @@
1
+ import express from 'express'
2
+ import cors from 'cors'
3
+
4
+ const app = express()
5
+ const PORT = process.env.PORT || 3001
6
+
7
+ app.use(cors())
8
+ app.use(express.json())
9
+
10
+ app.get('/api/health', (_req, res) => {
11
+ res.json({ status: 'ok' })
12
+ })
13
+
14
+ app.get('/api/hello', (_req, res) => {
15
+ res.json({ message: 'Hello from {{projectName}} backend!' })
16
+ })
17
+
18
+ app.listen(PORT, () => {
19
+ console.log(`Backend server is running on http://localhost:${PORT}`)
20
+ })
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "outDir": "./dist",
11
+ "rootDir": "./src",
12
+ "declaration": true,
13
+ "resolveJsonModule": true
14
+ },
15
+ "include": ["src/**/*"],
16
+ "exclude": ["node_modules", "dist"]
17
+ }
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from 'tsup'
2
+
3
+ export default defineConfig({
4
+ entry: ['src/index.ts'],
5
+ format: ['esm'],
6
+ target: 'node18',
7
+ clean: true,
8
+ dts: true
9
+ })
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>{{projectName}}</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "{{projectName}}-frontend",
3
+ "private": true,
4
+ "version": "0.1.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "react": "^18.3.1",
13
+ "react-dom": "^18.3.1"
14
+ },
15
+ "devDependencies": {
16
+ "@types/react": "^18.3.18",
17
+ "@types/react-dom": "^18.3.5",
18
+ "@vitejs/plugin-react": "^4.3.4",
19
+ "typescript": "^5.7.3",
20
+ "vite": "^6.0.7"
21
+ }
22
+ }
@@ -0,0 +1,16 @@
1
+ .app {
2
+ max-width: 800px;
3
+ margin: 0 auto;
4
+ padding: 2rem;
5
+ text-align: center;
6
+ }
7
+
8
+ h1 {
9
+ font-size: 2.5rem;
10
+ color: #333;
11
+ }
12
+
13
+ p {
14
+ font-size: 1.2rem;
15
+ color: #666;
16
+ }
@@ -0,0 +1,22 @@
1
+ import { useState, useEffect } from 'react'
2
+ import './App.css'
3
+
4
+ function App() {
5
+ const [message, setMessage] = useState<string>('')
6
+
7
+ useEffect(() => {
8
+ fetch('/api/hello')
9
+ .then(res => res.json())
10
+ .then(data => setMessage(data.message))
11
+ .catch(err => console.error(err))
12
+ }, [])
13
+
14
+ return (
15
+ <div className="app">
16
+ <h1>{{projectName}}</h1>
17
+ <p>来自后端的消息: {message || '加载中...'}</p>
18
+ </div>
19
+ )
20
+ }
21
+
22
+ export default App
@@ -0,0 +1,9 @@
1
+ import { StrictMode } from 'react'
2
+ import { createRoot } from 'react-dom/client'
3
+ import App from './App.tsx'
4
+
5
+ createRoot(document.getElementById('root')!).render(
6
+ <StrictMode>
7
+ <App />
8
+ </StrictMode>,
9
+ )
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+ "moduleResolution": "bundler",
9
+ "allowImportingTsExtensions": true,
10
+ "resolveJsonModule": true,
11
+ "isolatedModules": true,
12
+ "noEmit": true,
13
+ "jsx": "react-jsx",
14
+ "strict": true,
15
+ "noUnusedLocals": true,
16
+ "noUnusedParameters": true,
17
+ "noFallthroughCasesInSwitch": true
18
+ },
19
+ "include": ["src"]
20
+ }
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ server: {
7
+ proxy: {
8
+ '/api': {
9
+ target: 'http://localhost:3001',
10
+ changeOrigin: true
11
+ }
12
+ }
13
+ }
14
+ })
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "{{projectName}}",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "pnpm -r --parallel dev",
7
+ "build": "pnpm -r build",
8
+ "test": "pnpm -r test"
9
+ }
10
+ }
@@ -0,0 +1,3 @@
1
+ packages:
2
+ - 'frontend'
3
+ - 'backend'
@@ -0,0 +1,35 @@
1
+ .PHONY: install dev build test clean
2
+
3
+ # 安装所有依赖
4
+ install:
5
+ cd frontend && pnpm install
6
+ cd backend && uv sync
7
+
8
+ # 开发模式(并行启动前后端)
9
+ dev:
10
+ @echo "Starting development servers..."
11
+ @(cd backend && uv run uvicorn {{projectName}}.main:app --reload --port 8000) & \
12
+ (cd frontend && pnpm dev) & \
13
+ wait
14
+
15
+ # 仅启动后端
16
+ dev-backend:
17
+ cd backend && uv run uvicorn {{projectName}}.main:app --reload --port 8000
18
+
19
+ # 仅启动前端
20
+ dev-frontend:
21
+ cd frontend && pnpm dev
22
+
23
+ # 构建
24
+ build:
25
+ cd frontend && pnpm build
26
+
27
+ # 测试
28
+ test:
29
+ cd backend && uv run pytest
30
+ cd frontend && pnpm test 2>/dev/null || true
31
+
32
+ # 清理
33
+ clean:
34
+ rm -rf frontend/node_modules frontend/dist
35
+ rm -rf backend/.venv backend/__pycache__
@@ -0,0 +1,43 @@
1
+ # {{projectName}}
2
+
3
+ React + Python (FastAPI) 全栈项目
4
+
5
+ ## 项目结构
6
+
7
+ ```
8
+ {{projectName}}/
9
+ ├── frontend/ # React 前端 (Vite + pnpm)
10
+ ├── backend/ # FastAPI 后端 (uv)
11
+ ├── Makefile # 统一命令入口
12
+ └── README.md
13
+ ```
14
+
15
+ ## 开发
16
+
17
+ 同时启动前后端开发服务器:
18
+
19
+ ```bash
20
+ make dev
21
+ ```
22
+
23
+ - 前端: http://localhost:5173
24
+ - 后端: http://localhost:8000
25
+ - API 文档: http://localhost:8000/docs
26
+
27
+ ## 安装依赖
28
+
29
+ ```bash
30
+ make install
31
+ ```
32
+
33
+ ## 构建
34
+
35
+ ```bash
36
+ make build
37
+ ```
38
+
39
+ ## 测试
40
+
41
+ ```bash
42
+ make test
43
+ ```
@@ -0,0 +1,18 @@
1
+ node_modules/
2
+ dist/
3
+ *.log
4
+ .DS_Store
5
+ .env
6
+ .env.local
7
+ coverage/
8
+ __pycache__/
9
+ *.py[cod]
10
+ *$py.class
11
+ .Python
12
+ .venv/
13
+ venv/
14
+ env/
15
+ *.egg-info/
16
+ build/
17
+ .pytest_cache/
18
+ .ruff_cache/
@@ -0,0 +1,25 @@
1
+ {
2
+ "description": "React + Python (FastAPI) 全栈项目模板",
3
+ "packageManager": "pnpm",
4
+ "type": "workspace",
5
+ "postInit": [
6
+ {
7
+ "command": "make install",
8
+ "description": "安装依赖"
9
+ }
10
+ ],
11
+ "workspaces": [
12
+ {
13
+ "name": "frontend",
14
+ "packageManager": "pnpm"
15
+ },
16
+ {
17
+ "name": "backend",
18
+ "packageManager": "uv"
19
+ }
20
+ ],
21
+ "fileRenames": {
22
+ "_gitignore": ".gitignore",
23
+ "project_name": "{{projectName}}"
24
+ }
25
+ }
@@ -0,0 +1,21 @@
1
+ [project]
2
+ name = "{{projectName}}"
3
+ version = "0.1.0"
4
+ description = "FastAPI backend for {{projectName}}"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ dependencies = [
8
+ "fastapi>=0.115.0",
9
+ "uvicorn[standard]>=0.34.0",
10
+ ]
11
+
12
+ [build-system]
13
+ requires = ["hatchling"]
14
+ build-backend = "hatchling.build"
15
+
16
+ [tool.uv]
17
+ dev-dependencies = [
18
+ "pytest>=8.0.0",
19
+ "httpx>=0.27.0",
20
+ "ruff>=0.8.0",
21
+ ]
@@ -0,0 +1 @@
1
+ """{{projectName}} - FastAPI backend"""
@@ -0,0 +1,29 @@
1
+ from fastapi import FastAPI
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+ from .routes import router
4
+
5
+ app = FastAPI(
6
+ title="{{projectName}}",
7
+ description="FastAPI backend for {{projectName}}",
8
+ version="0.1.0"
9
+ )
10
+
11
+ app.add_middleware(
12
+ CORSMiddleware,
13
+ allow_origins=["http://localhost:5173"],
14
+ allow_credentials=True,
15
+ allow_methods=["*"],
16
+ allow_headers=["*"],
17
+ )
18
+
19
+ app.include_router(router, prefix="/api")
20
+
21
+
22
+ @app.get("/")
23
+ async def root():
24
+ return {"message": "Welcome to {{projectName}} API"}
25
+
26
+
27
+ @app.get("/health")
28
+ async def health():
29
+ return {"status": "ok"}
@@ -0,0 +1,8 @@
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.get("/hello")
7
+ async def hello():
8
+ return {"message": "Hello from {{projectName}} FastAPI backend!"}
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>{{projectName}}</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "{{projectName}}-frontend",
3
+ "private": true,
4
+ "version": "0.1.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "react": "^18.3.1",
13
+ "react-dom": "^18.3.1"
14
+ },
15
+ "devDependencies": {
16
+ "@types/react": "^18.3.18",
17
+ "@types/react-dom": "^18.3.5",
18
+ "@vitejs/plugin-react": "^4.3.4",
19
+ "typescript": "^5.7.3",
20
+ "vite": "^6.0.7"
21
+ }
22
+ }