-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(shell): add
chronocat.putongdejiekou1
api def
- Loading branch information
Showing
5 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters