|
@@ -1,4 +1,10 @@
|
|
|
-import { Request, RequestHandler, NextFunction, Router } from 'express'
|
|
|
+import {
|
|
|
+ Request,
|
|
|
+ RequestHandler,
|
|
|
+ NextFunction,
|
|
|
+ Router,
|
|
|
+ Response,
|
|
|
+} from 'express'
|
|
|
import { Controller } from '../types'
|
|
|
import jsonResponseMiddleware, {
|
|
|
JsonResponse,
|
|
@@ -13,8 +19,10 @@ import { TiktokData } from '../../db/models/Tiktok'
|
|
|
import { PaginationData } from '../../services/types'
|
|
|
import bnService, { BnData, BnRequest } from '../../services/bnService'
|
|
|
|
|
|
+// https://developers.binance.com/docs/w3w_task_verification_api/apis#general-api-information
|
|
|
+// 特殊化,直接从根开始/v1
|
|
|
export default class BnTask implements Controller {
|
|
|
- public path = '/api/v1'
|
|
|
+ public path = '/v1'
|
|
|
public router = Router()
|
|
|
|
|
|
constructor() {
|
|
@@ -25,7 +33,7 @@ export default class BnTask implements Controller {
|
|
|
this.router.get(
|
|
|
'/task/completion',
|
|
|
// apiKeyMiddleware(),
|
|
|
- jsonResponseMiddleware,
|
|
|
+ // jsonResponseMiddleware,
|
|
|
this.searchAddress as RequestHandler
|
|
|
)
|
|
|
this.router.get(
|
|
@@ -38,11 +46,11 @@ export default class BnTask implements Controller {
|
|
|
|
|
|
private time(
|
|
|
request: Request<any, any, any, { after?: string }>,
|
|
|
- response: JsonResponse<BnData>,
|
|
|
+ response: Response,
|
|
|
next: NextFunction
|
|
|
): void {
|
|
|
const currentTimestamp = Date.now()
|
|
|
- response.status(200).jsonSuccess({
|
|
|
+ response.status(200).json({
|
|
|
code: '000000',
|
|
|
message: 'success',
|
|
|
data: currentTimestamp.toString(),
|
|
@@ -51,16 +59,20 @@ export default class BnTask implements Controller {
|
|
|
|
|
|
private searchAddress(
|
|
|
request: Request<any, any, any, { after?: string }>,
|
|
|
- response: JsonResponse<BnData>,
|
|
|
+ response: Response<BnData>,
|
|
|
next: NextFunction
|
|
|
): void {
|
|
|
bnService
|
|
|
.searchStatus(request.query as BnRequest)
|
|
|
.then((bnData) => {
|
|
|
- response.status(200).jsonSuccess(bnData)
|
|
|
+ response.status(200).json(bnData)
|
|
|
})
|
|
|
.catch((e) => {
|
|
|
- response.status(500).jsonError('Server Error', 1010)
|
|
|
+ response.status(500).json({
|
|
|
+ code: '000007',
|
|
|
+ message: e.message,
|
|
|
+ data: null,
|
|
|
+ })
|
|
|
})
|
|
|
}
|
|
|
}
|