From 883a9019085ff9013079d6b1539b86f2f519175a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 16:02:11 +0200 Subject: Introduce debug command --- server/controllers/api/server/debug.ts | 6 +++--- server/helpers/database-utils.ts | 10 +++++----- server/tests/api/videos/resumable-upload.ts | 5 ++--- 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'server') diff --git a/server/controllers/api/server/debug.ts b/server/controllers/api/server/debug.ts index a6e9147f3..31888e963 100644 --- a/server/controllers/api/server/debug.ts +++ b/server/controllers/api/server/debug.ts @@ -1,8 +1,8 @@ +import * as express from 'express' import { InboxManager } from '@server/lib/activitypub/inbox-manager' import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler' +import { Debug, SendDebugCommand } from '@shared/models' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' -import { SendDebugCommand } from '@shared/models' -import * as express from 'express' import { UserRight } from '../../../../shared/models/users' import { authenticate, ensureUserHasRight } from '../../../middlewares' @@ -32,7 +32,7 @@ function getDebug (req: express.Request, res: express.Response) { return res.json({ ip: req.ip, activityPubMessagesWaiting: InboxManager.Instance.getActivityPubMessagesWaiting() - }) + } as Debug) } async function runCommand (req: express.Request, res: express.Response) { diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts index b5dc70c17..cbd7aa401 100644 --- a/server/helpers/database-utils.ts +++ b/server/helpers/database-utils.ts @@ -6,7 +6,7 @@ import { sequelizeTypescript } from '@server/initializers/database' import { logger } from './logger' function retryTransactionWrapper ( - functionToRetry: (arg1: A, arg2: B, arg3: C, arg4: D) => Promise | Bluebird, + functionToRetry: (arg1: A, arg2: B, arg3: C, arg4: D) => Promise, arg1: A, arg2: B, arg3: C, @@ -14,20 +14,20 @@ function retryTransactionWrapper ( ): Promise function retryTransactionWrapper ( - functionToRetry: (arg1: A, arg2: B, arg3: C) => Promise | Bluebird, + functionToRetry: (arg1: A, arg2: B, arg3: C) => Promise, arg1: A, arg2: B, arg3: C ): Promise function retryTransactionWrapper ( - functionToRetry: (arg1: A, arg2: B) => Promise | Bluebird, + functionToRetry: (arg1: A, arg2: B) => Promise, arg1: A, arg2: B ): Promise function retryTransactionWrapper ( - functionToRetry: (arg1: A) => Promise | Bluebird, + functionToRetry: (arg1: A) => Promise, arg1: A ): Promise @@ -36,7 +36,7 @@ function retryTransactionWrapper ( ): Promise function retryTransactionWrapper ( - functionToRetry: (...args: any[]) => Promise | Bluebird, + functionToRetry: (...args: any[]) => Promise, ...args: any[] ): Promise { return transactionRetryer(callback => { diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts index 4fc3317df..6c01c7e78 100644 --- a/server/tests/api/videos/resumable-upload.ts +++ b/server/tests/api/videos/resumable-upload.ts @@ -12,7 +12,6 @@ import { flushAndRunServer, getMyUserInformation, prepareResumableUpload, - sendDebugCommand, sendResumableChunks, ServerInfo, setAccessTokensToServers, @@ -138,13 +137,13 @@ describe('Test resumable upload', function () { }) it('Should not delete recent uploads', async function () { - await sendDebugCommand(server.url, server.accessToken, { command: 'remove-dandling-resumable-uploads' }) + await server.debugCommand.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } }) expect(await countResumableUploads()).to.equal(2) }) it('Should delete old uploads', async function () { - await sendDebugCommand(server.url, server.accessToken, { command: 'remove-dandling-resumable-uploads' }) + await server.debugCommand.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } }) expect(await countResumableUploads()).to.equal(0) }) -- cgit v1.2.3