新单只路由 affiliate_dash(未命中走 manual_dispatch);历史飞飞/乐玩任务保留只读 stub,避免订单重同步失败。同步清理 cloudtentacles 调度、Admin 写路径与相关 env。 Co-authored-by: Cursor <cursoragent@cursor.com>
59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
import { Router } from 'express'
|
|
|
|
import { createRateLimitMiddleware, getParamRateLimitKey } from '../middleware/rate-limit.js'
|
|
import {
|
|
getKuaishouCloudClaimDetail,
|
|
submitAffiliateDashClaim,
|
|
submitClaimUid,
|
|
} from '../services/claim/kuaishou-cloud-claim-service.js'
|
|
import { buildNotFoundPayload, createRouteHandler } from '../utils/http.js'
|
|
|
|
const router = Router()
|
|
const claimReadRateLimit = createRateLimitMiddleware({
|
|
scope: 'claim:read',
|
|
windowMs: 60_000,
|
|
max: 120,
|
|
key: getParamRateLimitKey('token'),
|
|
})
|
|
const claimWriteRateLimit = createRateLimitMiddleware({
|
|
scope: 'claim:write',
|
|
windowMs: 60_000,
|
|
max: 30,
|
|
key: getParamRateLimitKey('token'),
|
|
})
|
|
|
|
router.get(
|
|
'/:token',
|
|
claimReadRateLimit,
|
|
createRouteHandler((req) => getKuaishouCloudClaimDetail(req.params.token), {
|
|
errorMessage: '查询快手领取详情失败',
|
|
scope: '[claims/:token]',
|
|
}),
|
|
)
|
|
|
|
router.post(
|
|
'/:token/uid',
|
|
claimWriteRateLimit,
|
|
createRouteHandler((req) => submitClaimUid(req.params.token, req.body || {}), {
|
|
successMessage: 'UID 已提交',
|
|
errorMessage: '提交 UID 失败',
|
|
scope: '[claims/:token/uid]',
|
|
}),
|
|
)
|
|
|
|
router.post(
|
|
'/:token/affiliate-dash/submit',
|
|
claimWriteRateLimit,
|
|
createRouteHandler((req) => submitAffiliateDashClaim(req.params.token, req.body || {}), {
|
|
successMessage: '发货已提交',
|
|
errorMessage: '提交发货失败',
|
|
scope: '[claims/:token/affiliate-dash/submit]',
|
|
}),
|
|
)
|
|
|
|
router.use((req, res) => {
|
|
res.status(404).json(buildNotFoundPayload(req))
|
|
})
|
|
|
|
export default router
|