refactor: revert json schema changes

This commit is contained in:
2023-11-01 14:51:06 +01:00
parent d18a579cb8
commit c7555e1918
2 changed files with 44 additions and 42 deletions

View File

@@ -22,17 +22,17 @@ import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-lar
import {SCSyntaxErrorResponse} from '../errors/syntax-error.js'; import {SCSyntaxErrorResponse} from '../errors/syntax-error.js';
import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type.js'; import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type.js';
import {SCValidationErrorResponse} from '../errors/validation.js'; import {SCValidationErrorResponse} from '../errors/validation.js';
import {SCRoute, SCRouteHttpVerbs} from '../route.js'; import {SCAbstractRoute, SCRouteHttpVerbs} from '../route.js';
import {default as indexRequestSchema} from 'schema:#SCIndexRequest';
import {default as indexResponseSchema} from 'schema:#SCIndexResponse';
/** /**
* Index request * Index request
* @validatable
*/ */
export interface SCIndexRequest {} export interface SCIndexRequest {}
/** /**
* A response to an index request * A response to an index request
* @validatable
*/ */
export interface SCIndexResponse { export interface SCIndexResponse {
/** /**
@@ -54,20 +54,21 @@ export interface SCIndexResponse {
/** /**
* Route to request meta information about the deployment * Route to request meta information about the deployment
*/ */
export type SCIndexRoute = typeof indexRoute; export class SCIndexRoute extends SCAbstractRoute {
constructor() {
export const indexRoute = Object.freeze({ super();
errors: [ this.errorNames = [
SCInternalServerErrorResponse, SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse, SCMethodNotAllowedErrorResponse,
SCRequestBodyTooLargeErrorResponse, SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse, SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse, SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse, SCValidationErrorResponse,
] as const, ];
method: SCRouteHttpVerbs.POST, this.method = SCRouteHttpVerbs.POST;
requestBodySchema: indexRequestSchema, this.requestBodyName = 'SCIndexRequest';
responseBodySchema: indexResponseSchema, this.responseBodyName = 'SCIndexResponse';
statusCodeSuccess: StatusCodes.OK, this.statusCodeSuccess = StatusCodes.OK;
urlPath: '/', this.urlPath = '/';
}) satisfies Readonly<SCRoute>; }
}

View File

@@ -22,12 +22,11 @@ import {SCPluginAlreadyRegisteredErrorResponse} from '../errors/plugin-already-r
import {SCPluginRegisteringFailedErrorResponse} from '../errors/plugin-registering-failed.js'; import {SCPluginRegisteringFailedErrorResponse} from '../errors/plugin-registering-failed.js';
import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large.js'; import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large.js';
import {SCSyntaxErrorResponse} from '../errors/syntax-error.js'; import {SCSyntaxErrorResponse} from '../errors/syntax-error.js';
import {SCRoute, SCRouteHttpVerbs} from '../route.js'; import {SCAbstractRoute, SCRouteHttpVerbs} from '../route.js';
import {default as pluginRegisterRequestSchema} from 'schema:#SCPluginRegisterRequest';
import {default as pluginRegisterResponseSchema} from 'schema:#SCPluginRegisterResponse';
/** /**
* Plugin register request * Plugin register request
* @validatable
*/ */
export type SCPluginRegisterRequest = SCPluginAdd | SCPluginRemove; export type SCPluginRegisterRequest = SCPluginAdd | SCPluginRemove;
@@ -97,6 +96,7 @@ export interface SCPluginMetaData {
export interface SCPluginRegisterResponse { export interface SCPluginRegisterResponse {
/** /**
* Whether the desired action succeeded or failed (true for success, false if an error occurred) * Whether the desired action succeeded or failed (true for success, false if an error occurred)
* @validatable
*/ */
success: boolean; success: boolean;
} }
@@ -104,10 +104,10 @@ export interface SCPluginRegisterResponse {
/** /**
* Route to register plugins * Route to register plugins
*/ */
export type SCPluginRegisterRoute = typeof pluginRegisterRoute; export class SCPluginRegisterRoute extends SCAbstractRoute {
constructor() {
export const pluginRegisterRoute = Object.freeze({ super();
errors: [ this.errorNames = [
SCInternalServerErrorResponse, SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse, SCMethodNotAllowedErrorResponse,
SCNotFoundErrorResponse, SCNotFoundErrorResponse,
@@ -116,10 +116,11 @@ export const pluginRegisterRoute = Object.freeze({
SCPluginRegisteringFailedErrorResponse, SCPluginRegisteringFailedErrorResponse,
SCRequestBodyTooLargeErrorResponse, SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse, SCSyntaxErrorResponse,
], ];
method: SCRouteHttpVerbs.POST, this.method = SCRouteHttpVerbs.POST;
requestBodySchema: pluginRegisterRequestSchema, this.requestBodyName = 'SCPluginRegisterRequest';
responseBodySchema: pluginRegisterResponseSchema, this.responseBodyName = 'SCPluginRegisterResponse';
statusCodeSuccess: StatusCodes.OK, this.statusCodeSuccess = StatusCodes.OK;
urlPath: '/plugin/register', this.urlPath = '/plugin/register';
}) satisfies Readonly<SCRoute>; }
}