create-skweb 1.1.5 → 2.1.0

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.
@@ -0,0 +1,54 @@
1
+ import path from 'path'
2
+ import { fileURLToPath } from 'url'
3
+ import swaggerJSDoc from 'swagger-jsdoc'
4
+
5
+ const __filename = fileURLToPath(import.meta.url)
6
+ const __dirname = path.dirname(__filename)
7
+
8
+ /**
9
+ * 构建 OpenAPI 3.0 规范对象。
10
+ *
11
+ * 控制器中应使用 @swagger JSDoc 注释描述端点,例如:
12
+ *
13
+ * /**
14
+ * * @swagger
15
+ * * /api/users:
16
+ * * get:
17
+ * * summary: 获取用户列表
18
+ * * tags: [Users]
19
+ * * responses:
20
+ * * 200:
21
+ * * description: OK
22
+ * *\/
23
+ */
24
+ export function buildOpenApiSpec(): object {
25
+ return swaggerJSDoc({
26
+ definition: {
27
+ openapi: '3.0.3',
28
+ info: {
29
+ title: process.env.APP_NAME || 'SKWeb API',
30
+ version: process.env.API_VERSION || '1.0.0',
31
+ description: process.env.APP_DESCRIPTION || 'SKWeb project API documentation',
32
+ contact: { name: 'API Support' }
33
+ },
34
+ servers: [
35
+ { url: `http://localhost:${process.env.PORT || 3000}`, description: 'Local development' }
36
+ ],
37
+ components: {
38
+ securitySchemes: {
39
+ bearerAuth: {
40
+ type: 'http',
41
+ scheme: 'bearer',
42
+ bearerFormat: 'JWT',
43
+ description: 'Paste a JWT token here (only needed when AUTH_PROVIDER=static)'
44
+ }
45
+ }
46
+ }
47
+ },
48
+ // 扫描 controllers 目录与 src 根下的 JSDoc 注释
49
+ apis: [
50
+ path.join(__dirname, 'controllers', '*.ts'),
51
+ path.join(__dirname, 'controllers', '*.js')
52
+ ]
53
+ })
54
+ }
@@ -1,14 +0,0 @@
1
- const fs = require('fs')
2
- const path = require('path')
3
-
4
- const target = path.join(__dirname, '..', 'dist', 'cli.cjs')
5
- const shebang = '#!/usr/bin/env node\n'
6
-
7
- let content = fs.readFileSync(target, 'utf-8')
8
- if (!content.startsWith('#!')) {
9
- content = shebang + content
10
- fs.writeFileSync(target, content)
11
- console.log('[inject-shebang] Shebang added to dist/cli.cjs')
12
- } else {
13
- console.log('[inject-shebang] Shebang already present')
14
- }