Skip to content

Commit b6cefef

Browse files
fix(api-server): Various fixes and improvements (#2496)
1 parent 9d7e2a0 commit b6cefef

File tree

3 files changed

+17
-38
lines changed

3 files changed

+17
-38
lines changed

src/plugins/api-server/backend/main.ts

+14
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,26 @@ export const backend = createBackend<BackendType, APIServerConfig>({
7373
registerAuth(this.app, ctx);
7474

7575
// swagger
76+
this.app.openAPIRegistry.registerComponent(
77+
'securitySchemes',
78+
'bearerAuth',
79+
{
80+
type: 'http',
81+
scheme: 'bearer',
82+
bearerFormat: 'JWT',
83+
},
84+
);
7685
this.app.doc('/doc', {
7786
openapi: '3.1.0',
7887
info: {
7988
version: '1.0.0',
8089
title: 'Youtube Music API Server',
8190
},
91+
security: [
92+
{
93+
bearerAuth: [],
94+
},
95+
],
8296
});
8397

8498
this.app.get('/swagger', swaggerUI({ url: '/doc' }));

src/plugins/api-server/backend/routes/auth.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const routes = {
1818
path: '/auth/{id}',
1919
summary: '',
2020
description: '',
21+
security: [],
2122
request: {
2223
params: z.object({
2324
id: z.string(),
@@ -56,11 +57,11 @@ export const register = (
5657
title: t('plugins.api-server.dialog.request.title'),
5758
message: t('plugins.api-server.dialog.request.message', {
5859
origin: getConnInfo(ctx).remote.address,
59-
id,
60+
ID: id,
6061
}),
6162
buttons: [
6263
t('plugins.api-server.dialog.request.buttons.allow'),
63-
t('plugins.api-server.dialog.request.deny'),
64+
t('plugins.api-server.dialog.request.buttons.deny'),
6465
],
6566
defaultId: 1,
6667
cancelId: 1,

src/plugins/api-server/backend/routes/control.ts

-36
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ const routes = {
2929
path: `/api/${API_VERSION}/previous`,
3030
summary: 'play previous song',
3131
description: 'Plays the previous song in the queue',
32-
request: {
33-
headers: AuthHeadersSchema,
34-
},
3532
responses: {
3633
204: {
3734
description: 'Success',
@@ -43,9 +40,6 @@ const routes = {
4340
path: `/api/${API_VERSION}/next`,
4441
summary: 'play next song',
4542
description: 'Plays the next song in the queue',
46-
request: {
47-
headers: AuthHeadersSchema,
48-
},
4943
responses: {
5044
204: {
5145
description: 'Success',
@@ -57,9 +51,6 @@ const routes = {
5751
path: `/api/${API_VERSION}/play`,
5852
summary: 'Play',
5953
description: 'Change the state of the player to play',
60-
request: {
61-
headers: AuthHeadersSchema,
62-
},
6354
responses: {
6455
204: {
6556
description: 'Success',
@@ -71,9 +62,6 @@ const routes = {
7162
path: `/api/${API_VERSION}/pause`,
7263
summary: 'Pause',
7364
description: 'Change the state of the player to pause',
74-
request: {
75-
headers: AuthHeadersSchema,
76-
},
7765
responses: {
7866
204: {
7967
description: 'Success',
@@ -86,9 +74,6 @@ const routes = {
8674
summary: 'Toggle play/pause',
8775
description:
8876
'Change the state of the player to play if paused, or pause if playing',
89-
request: {
90-
headers: AuthHeadersSchema,
91-
},
9277
responses: {
9378
204: {
9479
description: 'Success',
@@ -100,9 +85,6 @@ const routes = {
10085
path: `/api/${API_VERSION}/like`,
10186
summary: 'like song',
10287
description: 'Set the current song as liked',
103-
request: {
104-
headers: AuthHeadersSchema,
105-
},
10688
responses: {
10789
204: {
10890
description: 'Success',
@@ -114,9 +96,6 @@ const routes = {
11496
path: `/api/${API_VERSION}/dislike`,
11597
summary: 'dislike song',
11698
description: 'Set the current song as disliked',
117-
request: {
118-
headers: AuthHeadersSchema,
119-
},
12099
responses: {
121100
204: {
122101
description: 'Success',
@@ -175,9 +154,6 @@ const routes = {
175154
path: `/api/${API_VERSION}/shuffle`,
176155
summary: 'shuffle',
177156
description: 'Shuffle the queue',
178-
request: {
179-
headers: AuthHeadersSchema,
180-
},
181157
responses: {
182158
204: {
183159
description: 'Success',
@@ -255,9 +231,6 @@ const routes = {
255231
path: `/api/${API_VERSION}/toggle-mute`,
256232
summary: 'toggle mute',
257233
description: 'Toggle the mute state of the player',
258-
request: {
259-
headers: AuthHeadersSchema,
260-
},
261234
responses: {
262235
204: {
263236
description: 'Success',
@@ -270,9 +243,6 @@ const routes = {
270243
path: `/api/${API_VERSION}/fullscreen`,
271244
summary: 'get fullscreen state',
272245
description: 'Get the current fullscreen state',
273-
request: {
274-
headers: AuthHeadersSchema,
275-
},
276246
responses: {
277247
200: {
278248
description: 'Success',
@@ -291,9 +261,6 @@ const routes = {
291261
path: `/api/${API_VERSION}/queue-info`,
292262
summary: 'get current queue info',
293263
description: 'Get the current queue info',
294-
request: {
295-
headers: AuthHeadersSchema,
296-
},
297264
responses: {
298265
200: {
299266
description: 'Success',
@@ -313,9 +280,6 @@ const routes = {
313280
path: `/api/${API_VERSION}/song-info`,
314281
summary: 'get current song info',
315282
description: 'Get the current song info',
316-
request: {
317-
headers: AuthHeadersSchema,
318-
},
319283
responses: {
320284
200: {
321285
description: 'Success',

0 commit comments

Comments
 (0)