Skip to content

Commit

Permalink
feat(shell): add chronocat.putongdejiekou1 api def
Browse files Browse the repository at this point in the history
  • Loading branch information
ilharp committed May 27, 2024
1 parent 890ea37 commit 72a9ac8
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/shell/src/satori/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { messageDelete } from './message/delete'
import { messageGet } from './message/get'
import { messageList } from './message/list'
import { notImplemented } from './notimpl'
import { puTongDeJieKou1 } from './putongdejiekou/1'
import type { Route } from './types'
import { userChannelCreate } from './user/channel/create'
import { userGet } from './user/get'
Expand Down Expand Up @@ -63,6 +64,7 @@ const routesIntl = {
'friend.list': friendList,
'friend.approve': friendApprove,
'unsafe.friend.remove': friendRemove,
'chronocat.putongdejiekou1': puTongDeJieKou1,
} as const

export type Routes = keyof typeof routesIntl
Expand Down
30 changes: 30 additions & 0 deletions packages/shell/src/satori/routes/putongdejiekou/1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { PuTongDeJieKou1Payload } from '../../types'
import type { RouteContext } from '../types'

export const puTongDeJieKou1 = async ({
cctx,
path,
req,
res,
json,
}: RouteContext) => {
const payload = (await json()) as PuTongDeJieKou1Payload

const validateResult = await cctx.chronocat.validate(
'PuTongDeJieKou1Payload',
)(payload)

if (validateResult) {
const err = `解析 ${path} 请求时出现问题,来自 ${req.socket.remoteAddress}${validateResult}`

cctx.chronocat.l.error(err, {
code: 400,
})

res.writeHead(400)
res.end(`400 bad request\n${err}`)
return
}

return await cctx.chronocat.api['chronocat.putongdejiekou1'](payload)
}
7 changes: 7 additions & 0 deletions packages/shell/src/satori/types/satoriPayloadEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,10 @@ export interface GuildMemberTitleSetPayload {
*/
title?: string
}

export interface PuTongDeJieKou1Payload {
g: string
a: string
b: string
d: string
}
1 change: 1 addition & 0 deletions packages/shell/src/satori/types/satoriPayloadRich.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type {
MessageListPayload,
MessageListResponse,
Next,
PuTongDeJieKou1Payload,
UserGetPayload,
UserPayload,
} from './satoriPayloadEntity'
Expand Down
3 changes: 3 additions & 0 deletions packages/shell/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import type {
MessageListPayload,
MessageListResponse,
Next,
PuTongDeJieKou1Payload,
User,
UserGetPayload,
UserPayload,
Expand Down Expand Up @@ -137,6 +138,8 @@ export interface SatoriMethods {
'friend.list': [[Next], FriendListResponse]
'friend.approve': [[ApprovePayload], Record<string, never>]
'unsafe.friend.remove': [[UserPayload], Record<string, never>]

'chronocat.putongdejiekou1': [[PuTongDeJieKou1Payload], Record<string, never>]
}

export interface CCInternalMethods {
Expand Down

0 comments on commit 72a9ac8

Please sign in to comment.