feat(shell): add chronocat.putongdejiekou1 api def

This commit is contained in:
Il Harper 2024-05-27 20:56:41 +08:00
parent 890ea371ab
commit 72a9ac8fe8
No known key found for this signature in database
GPG Key ID: 4B71FCA698E7E8EC
5 changed files with 43 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import { messageDelete } from './message/delete'
import { messageGet } from './message/get' import { messageGet } from './message/get'
import { messageList } from './message/list' import { messageList } from './message/list'
import { notImplemented } from './notimpl' import { notImplemented } from './notimpl'
import { puTongDeJieKou1 } from './putongdejiekou/1'
import type { Route } from './types' import type { Route } from './types'
import { userChannelCreate } from './user/channel/create' import { userChannelCreate } from './user/channel/create'
import { userGet } from './user/get' import { userGet } from './user/get'
@ -63,6 +64,7 @@ const routesIntl = {
'friend.list': friendList, 'friend.list': friendList,
'friend.approve': friendApprove, 'friend.approve': friendApprove,
'unsafe.friend.remove': friendRemove, 'unsafe.friend.remove': friendRemove,
'chronocat.putongdejiekou1': puTongDeJieKou1,
} as const } as const
export type Routes = keyof typeof routesIntl export type Routes = keyof typeof routesIntl

View File

@ -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)
}

View File

@ -165,3 +165,10 @@ export interface GuildMemberTitleSetPayload {
*/ */
title?: string title?: string
} }
export interface PuTongDeJieKou1Payload {
g: string
a: string
b: string
d: string
}

View File

@ -23,6 +23,7 @@ export type {
MessageListPayload, MessageListPayload,
MessageListResponse, MessageListResponse,
Next, Next,
PuTongDeJieKou1Payload,
UserGetPayload, UserGetPayload,
UserPayload, UserPayload,
} from './satoriPayloadEntity' } from './satoriPayloadEntity'

View File

@ -32,6 +32,7 @@ import type {
MessageListPayload, MessageListPayload,
MessageListResponse, MessageListResponse,
Next, Next,
PuTongDeJieKou1Payload,
User, User,
UserGetPayload, UserGetPayload,
UserPayload, UserPayload,
@ -137,6 +138,8 @@ export interface SatoriMethods {
'friend.list': [[Next], FriendListResponse] 'friend.list': [[Next], FriendListResponse]
'friend.approve': [[ApprovePayload], Record<string, never>] 'friend.approve': [[ApprovePayload], Record<string, never>]
'unsafe.friend.remove': [[UserPayload], Record<string, never>] 'unsafe.friend.remove': [[UserPayload], Record<string, never>]
'chronocat.putongdejiekou1': [[PuTongDeJieKou1Payload], Record<string, never>]
} }
export interface CCInternalMethods { export interface CCInternalMethods {