Skip to content

Commit

Permalink
feat: 初始化
Browse files Browse the repository at this point in the history
  • Loading branch information
geekact committed Jul 16, 2024
1 parent d0a7fd9 commit 7350225
Show file tree
Hide file tree
Showing 58 changed files with 4,982 additions and 3,648 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ jobs:
cache: 'pnpm'
node-version-file: 'package.json'
- run: pnpm install
- run: npx lerna version --force-publish --yes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
pnpm --recursive publish
pnpm publish
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ coverage/
.DS_Store
*.log
.tsbuildinfo
.nx/
*.js
*.d.ts
*.d.cts
*.d.mts
*.js.map
/adapters
openapi/openapi.yaml
openapi/openapi.json
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.preferences.quoteStyle": "single",
"typescript.suggest.autoImports": true,
"cSpell.words": ["openapi"]
"cSpell.words": ["aomex", "openapi"]
}
32 changes: 32 additions & 0 deletions cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ConsoleApp } from '@aomex/console';
import { openapi } from '@aomex/openapi';

const app = new ConsoleApp({
mount: [
openapi({
commandName: 'openapi-json',
routers: ['./openapi/routers'],
saveToFile: './openapi/openapi.json',
docs: {
openapi: '3.0.3',
info: {
version: '0.0.0',
},
},
}),
openapi({
commandName: 'openapi-yaml',
routers: ['./openapi/routers'],
saveToFile: './openapi/openapi.yaml',
docs: {
openapi: '3.0.3',
info: {
version: '0.0.0',
},
},
}),
],
});

const code = await app.run();
process.exit(code);
16 changes: 0 additions & 16 deletions lerna.json

This file was deleted.

5 changes: 5 additions & 0 deletions openapi.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from './src/define-config';

export default defineConfig({
path: './openapi/openapi.json',
});
1 change: 1 addition & 0 deletions openapi/openapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"openapi":"3.0.3","info":{"version":"0.0.0","title":"foca-openapi"},"tags":[{"name":"user"}],"paths":{"/users":{"get":{"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"page":{"type":"integer"},"limit":{"type":"integer"},"total":{"type":"integer"},"result":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer"},"name":{"description":"用户名","type":"string"},"age":{"nullable":true,"type":"integer"},"address":{"nullable":true,"type":"string"},"password":{"description":"即将删除","deprecated":true,"type":"string"}},"required":["id","name","age","password"]}}},"required":["page","limit","total","result"]}}}}},"parameters":[{"name":"page","in":"query","schema":{"default":1,"type":"integer","maximum":10,"minimum":1,"exclusiveMaximum":false,"exclusiveMinimum":false}},{"name":"limit","in":"query","description":"每页返回的资源数量","schema":{"description":"每页返回的资源数量","default":10,"type":"integer","maximum":100,"exclusiveMaximum":false}}],"tags":["user"],"operationId":"list_users"},"post":{"responses":{"201":{"description":"创建成功","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"integer"},"name":{"description":"用户名","type":"string"},"age":{"nullable":true,"type":"integer"},"address":{"nullable":true,"type":"string"},"password":{"description":"即将删除","deprecated":true,"type":"string"}},"required":["id","name","age","password"]}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"age":{"type":"integer"},"address":{"type":"integer"}},"required":["name"]}}},"required":true},"tags":["user"],"operationId":"create_users","x-codegen-request-body-name":"body"}},"/users/{id}":{"get":{"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"integer"},"name":{"description":"用户名","type":"string"},"age":{"nullable":true,"type":"integer"},"address":{"nullable":true,"type":"string"},"password":{"description":"即将删除","deprecated":true,"type":"string"}},"required":["id","name","age","password"]}}}},"404":{"description":"用户不存在"}},"tags":["user"],"operationId":"retrieve_users_by_id"},"put":{"responses":{"200":{"description":"更新成功","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"integer"},"name":{"description":"用户名","type":"string"},"age":{"nullable":true,"type":"integer"},"address":{"nullable":true,"type":"string"},"password":{"description":"即将删除","deprecated":true,"type":"string"}},"required":["id","name","age","password"]}}}},"404":{"description":"用户不存在"}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"age":{"type":"integer"},"address":{"type":"integer"}},"required":["name"]}}},"required":true},"tags":["user"],"operationId":"replace_users_by_id"},"delete":{"responses":{"204":{"description":"删除成功"},"404":{"description":"用户不存在"}},"tags":["user"],"operationId":"delete_users_by_id"},"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1,"exclusiveMinimum":false}}]},"/users/v1":{"post":{"deprecated":true,"description":"接口已弃用,请使用 /users","responses":{"201":{"description":"创建成功","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"integer"},"name":{"description":"用户名","type":"string"},"age":{"nullable":true,"type":"integer"},"address":{"nullable":true,"type":"string"},"password":{"description":"即将删除","deprecated":true,"type":"string"}},"required":["id","name","age","password"]}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"age":{"type":"integer"},"address":{"type":"integer"}},"required":["name"]}}},"required":true},"tags":["user"],"operationId":"create_users_v_1","x-codegen-request-body-name":"body"}},"/users/avatar":{"put":{"responses":{"201":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string"}},"required":["url"]}}}}},"requestBody":{"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary"}},"required":["file"]}}},"required":true},"tags":["user"],"operationId":"replace_users_avatar"}}}}
304 changes: 304 additions & 0 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,304 @@
openapi: 3.0.3
info:
version: 0.0.0
title: foca-openapi
tags:
- name: user
paths:
/users:
get:
responses:
"200":
description: ""
content:
application/json:
schema:
type: object
properties:
page:
type: integer
limit:
type: integer
total:
type: integer
result:
type: array
items:
type: object
properties:
id:
type: integer
name:
description: 用户名
type: string
age:
nullable: true
type: integer
address:
nullable: true
type: string
password:
description: 即将删除
deprecated: true
type: string
required:
- id
- name
- age
- password
required:
- page
- limit
- total
- result
parameters:
- name: page
in: query
schema:
default: 1
type: integer
maximum: 10
minimum: 1
exclusiveMaximum: false
exclusiveMinimum: false
- name: limit
in: query
description: 每页返回的资源数量
schema:
description: 每页返回的资源数量
default: 10
type: integer
maximum: 100
exclusiveMaximum: false
tags:
- user
operationId: list_users
post:
responses:
"201":
description: 创建成功
content:
application/json:
schema:
type: object
properties:
id:
type: integer
name:
description: 用户名
type: string
age:
nullable: true
type: integer
address:
nullable: true
type: string
password:
description: 即将删除
deprecated: true
type: string
required:
- id
- name
- age
- password
requestBody:
content:
application/json:
schema:
type: object
properties:
name:
type: string
age:
type: integer
address:
type: integer
required:
- name
required: true
tags:
- user
operationId: create_users
x-codegen-request-body-name: body
/users/{id}:
get:
responses:
"200":
description: ""
content:
application/json:
schema:
type: object
properties:
id:
type: integer
name:
description: 用户名
type: string
age:
nullable: true
type: integer
address:
nullable: true
type: string
password:
description: 即将删除
deprecated: true
type: string
required:
- id
- name
- age
- password
"404":
description: 用户不存在
tags:
- user
operationId: retrieve_users_by_id
put:
responses:
"200":
description: 更新成功
content:
application/json:
schema:
type: object
properties:
id:
type: integer
name:
description: 用户名
type: string
age:
nullable: true
type: integer
address:
nullable: true
type: string
password:
description: 即将删除
deprecated: true
type: string
required:
- id
- name
- age
- password
"404":
description: 用户不存在
requestBody:
content:
application/json:
schema:
type: object
properties:
name:
type: string
age:
type: integer
address:
type: integer
required:
- name
required: true
tags:
- user
operationId: replace_users_by_id
delete:
responses:
"204":
description: 删除成功
"404":
description: 用户不存在
tags:
- user
operationId: delete_users_by_id
parameters:
- name: id
in: path
required: true
schema:
type: integer
minimum: 1
exclusiveMinimum: false
/users/v1:
post:
deprecated: true
description: 接口已弃用,请使用 /users
responses:
"201":
description: 创建成功
content:
application/json:
schema:
type: object
properties:
id:
type: integer
name:
description: 用户名
type: string
age:
nullable: true
type: integer
address:
nullable: true
type: string
password:
description: 即将删除
deprecated: true
type: string
required:
- id
- name
- age
- password
requestBody:
content:
application/json:
schema:
type: object
properties:
name:
type: string
age:
type: integer
address:
type: integer
required:
- name
required: true
tags:
- user
operationId: create_users_v_1
x-codegen-request-body-name: body
/users/avatar:
put:
responses:
"201":
description: ""
content:
application/json:
schema:
type: object
properties:
url:
type: string
required:
- url
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
required:
- file
required: true
tags:
- user
operationId: replace_users_avatar
3 changes: 3 additions & 0 deletions openapi/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Loading

0 comments on commit 7350225

Please sign in to comment.