Skip to content

Commit 05719c3

Browse files
author
Lasim
committed
Refactor API specifications and update authentication hooks
- Removed deprecated API endpoints from api-spec.json and api-spec.yaml. - Added request body schemas for change password and update profile routes in API specifications. - Updated route definitions to use preValidation instead of preHandler for authentication checks in various routes. - Cleaned up imports in global settings routes by removing unnecessary FastifyRequest and FastifyReply types. - Updated GitHub service to handle explicit any types and added ESLint disables where necessary. - Enhanced GitHub App settings component with i18n support for better localization. - Removed unused components and code in various Vue files to streamline the application.
1 parent ce81827 commit 05719c3

File tree

35 files changed

+230
-136
lines changed

35 files changed

+230
-136
lines changed

services/backend/api-spec.json

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,6 @@
1616
"schemas": {}
1717
},
1818
"paths": {
19-
"/api/plugin/example-plugin/examples": {
20-
"get": {
21-
"responses": {
22-
"200": {
23-
"description": "Default Response"
24-
}
25-
}
26-
}
27-
},
28-
"/api/plugin/example-plugin/examples/{id}": {
29-
"get": {
30-
"parameters": [
31-
{
32-
"schema": {
33-
"type": "string"
34-
},
35-
"in": "path",
36-
"name": "id",
37-
"required": true
38-
}
39-
],
40-
"responses": {
41-
"200": {
42-
"description": "Default Response"
43-
}
44-
}
45-
}
46-
},
4719
"/": {
4820
"get": {
4921
"summary": "API health check",
@@ -12465,6 +12437,32 @@
1246512437
"Authentication"
1246612438
],
1246712439
"description": "Allows authenticated users to change their password by providing their current password and a new password. Requires an active session. Requires Content-Type: application/json header when sending request body.",
12440+
"requestBody": {
12441+
"content": {
12442+
"application/json": {
12443+
"schema": {
12444+
"type": "object",
12445+
"properties": {
12446+
"current_password": {
12447+
"type": "string",
12448+
"minLength": 1
12449+
},
12450+
"new_password": {
12451+
"type": "string",
12452+
"minLength": 8,
12453+
"maxLength": 100
12454+
}
12455+
},
12456+
"required": [
12457+
"current_password",
12458+
"new_password"
12459+
],
12460+
"additionalProperties": false
12461+
}
12462+
}
12463+
},
12464+
"required": true
12465+
},
1246812466
"security": [
1246912467
{
1247012468
"cookieAuth": []
@@ -13300,6 +13298,32 @@
1330013298
"Authentication"
1330113299
],
1330213300
"description": "Allows authenticated users to update their profile information including username, first name, and last name. Requires an active session. At least one field must be provided. Requires Content-Type: application/json header when sending request body.",
13301+
"requestBody": {
13302+
"content": {
13303+
"application/json": {
13304+
"schema": {
13305+
"type": "object",
13306+
"properties": {
13307+
"username": {
13308+
"type": "string",
13309+
"minLength": 3,
13310+
"maxLength": 30,
13311+
"pattern": "^[a-zA-Z0-9_]+$"
13312+
},
13313+
"first_name": {
13314+
"type": "string",
13315+
"maxLength": 50
13316+
},
13317+
"last_name": {
13318+
"type": "string",
13319+
"maxLength": 50
13320+
}
13321+
},
13322+
"additionalProperties": false
13323+
}
13324+
}
13325+
}
13326+
},
1330313327
"security": [
1330413328
{
1330513329
"cookieAuth": []

services/backend/api-spec.yaml

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,6 @@ components:
1111
name: auth_session
1212
schemas: {}
1313
paths:
14-
/api/plugin/example-plugin/examples:
15-
get:
16-
responses:
17-
"200":
18-
description: Default Response
19-
/api/plugin/example-plugin/examples/{id}:
20-
get:
21-
parameters:
22-
- schema:
23-
type: string
24-
in: path
25-
name: id
26-
required: true
27-
responses:
28-
"200":
29-
description: Default Response
3014
/:
3115
get:
3216
summary: API health check
@@ -8703,6 +8687,24 @@ paths:
87038687
their current password and a new password. Requires an active session.
87048688
Requires Content-Type: application/json header when sending request
87058689
body."
8690+
requestBody:
8691+
content:
8692+
application/json:
8693+
schema:
8694+
type: object
8695+
properties:
8696+
current_password:
8697+
type: string
8698+
minLength: 1
8699+
new_password:
8700+
type: string
8701+
minLength: 8
8702+
maxLength: 100
8703+
required:
8704+
- current_password
8705+
- new_password
8706+
additionalProperties: false
8707+
required: true
87068708
security:
87078709
- cookieAuth: []
87088710
responses:
@@ -9296,6 +9298,24 @@ paths:
92969298
including username, first name, and last name. Requires an active
92979299
session. At least one field must be provided. Requires Content-Type:
92989300
application/json header when sending request body."
9301+
requestBody:
9302+
content:
9303+
application/json:
9304+
schema:
9305+
type: object
9306+
properties:
9307+
username:
9308+
type: string
9309+
minLength: 3
9310+
maxLength: 30
9311+
pattern: ^[a-zA-Z0-9_]+$
9312+
first_name:
9313+
type: string
9314+
maxLength: 50
9315+
last_name:
9316+
type: string
9317+
maxLength: 50
9318+
additionalProperties: false
92999319
security:
93009320
- cookieAuth: []
93019321
responses:

services/backend/src/routes/auth/adminResetPassword.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default async function adminResetPasswordRoute(fastify: FastifyInstance)
5959
'/admin/reset-password',
6060
{
6161
schema: adminResetPasswordRouteSchema,
62-
preHandler: requireGlobalAdmin()
62+
preValidation: requireGlobalAdmin()
6363
},
6464
async (request: FastifyRequest, reply: FastifyReply) => {
6565
try {

services/backend/src/routes/auth/changePassword.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ const changePasswordRouteSchema = {
2525
tags: ['Authentication'],
2626
summary: 'Change user password',
2727
description: 'Allows authenticated users to change their password by providing their current password and a new password. Requires an active session. Requires Content-Type: application/json header when sending request body.',
28+
body: zodToJsonSchema(ChangePasswordSchema, {
29+
$refStrategy: 'none',
30+
target: 'openApi3'
31+
}),
2832
requestBody: {
2933
required: true,
3034
content: {
@@ -66,7 +70,7 @@ export default async function changePasswordRoute(fastify: FastifyInstance) {
6670
'/change-password',
6771
{
6872
schema: changePasswordRouteSchema,
69-
preHandler: requireAuthHook // Require authentication
73+
preValidation: requireAuthHook // Require authentication
7074
},
7175
async (request: FastifyRequest, reply: FastifyReply) => {
7276
try {

services/backend/src/routes/auth/updateProfile.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const updateProfileRouteSchema = {
3131
tags: ['Authentication'],
3232
summary: 'Update user profile',
3333
description: 'Allows authenticated users to update their profile information including username, first name, and last name. Requires an active session. At least one field must be provided. Requires Content-Type: application/json header when sending request body.',
34+
body: zodToJsonSchema(UpdateProfileSchema, {
35+
$refStrategy: 'none',
36+
target: 'openApi3'
37+
}),
3438
requestBody: {
3539
required: true,
3640
content: {
@@ -72,7 +76,7 @@ export default async function updateProfileRoute(fastify: FastifyInstance) {
7276
'/profile/update',
7377
{
7478
schema: updateProfileRouteSchema,
75-
preHandler: requireAuthHook // Require authentication
79+
preValidation: requireAuthHook // Require authentication
7680
},
7781
async (request: FastifyRequest, reply: FastifyReply) => {
7882
try {

services/backend/src/routes/globalSettings/categories/list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
1+
import type { FastifyInstance } from 'fastify';
22
import { zodToJsonSchema } from 'zod-to-json-schema';
33
import { GlobalSettingsService } from '../../../services/globalSettingsService';
44
import { requireGlobalAdmin } from '../../../middleware/roleMiddleware';

services/backend/src/routes/globalSettings/github/test-connection.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
1+
import type { FastifyInstance } from 'fastify';
22
import { zodToJsonSchema } from 'zod-to-json-schema';
33
import { requireGlobalAdmin } from '../../../middleware/roleMiddleware';
44
import { GitHubService } from '../../../services/githubService';
@@ -76,6 +76,7 @@ export default async function githubTestConnectionRoute(fastify: FastifyInstance
7676
endpoint: '/settings/github-app/test-connection',
7777
method: 'POST',
7878
userId: request.user?.id,
79+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
7980
requestId: (request as any).id
8081
}, '🚀 GitHub App connection test endpoint reached');
8182

services/backend/src/routes/globalSettings/groups/get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
1+
import type { FastifyInstance } from 'fastify';
22
import { zodToJsonSchema } from 'zod-to-json-schema';
33
import { GlobalSettingsService } from '../../../services/globalSettingsService';
44
import { requireGlobalAdmin } from '../../../middleware/roleMiddleware';

services/backend/src/routes/globalSettings/health/check.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
1+
import type { FastifyInstance } from 'fastify';
22
import { zodToJsonSchema } from 'zod-to-json-schema';
33
import { validateEncryption } from '../../../utils/encryption';
44
import { requireGlobalAdmin } from '../../../middleware/roleMiddleware';

services/backend/src/routes/globalSettings/settings/bulk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
1+
import type { FastifyInstance } from 'fastify';
22
import { ZodError } from 'zod';
33
import { zodToJsonSchema } from 'zod-to-json-schema';
44
import { GlobalSettingsService } from '../../../services/globalSettingsService';

0 commit comments

Comments
 (0)