recator placement of code
This commit is contained in:
88
backend/scaler/datamartAdd.spec.ts
Normal file
88
backend/scaler/datamartAdd.spec.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import type { OpenAPIV3_1 } from "openapi-types";
|
||||
|
||||
export const datamartAddSpec: OpenAPIV3_1.PathsObject = {
|
||||
"/api/datamart": {
|
||||
post: {
|
||||
summary: "New datamart query",
|
||||
description:
|
||||
"Creates a new query entry in the datamart. Must be called on the main server. The SQL can be provided as a file upload.",
|
||||
tags: ["Datamart"],
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
"multipart/form-data": {
|
||||
schema: {
|
||||
type: "object",
|
||||
required: ["name", "description", "queryFile"],
|
||||
properties: {
|
||||
name: {
|
||||
type: "string",
|
||||
example: "active_av",
|
||||
description: "Unique name for the query",
|
||||
},
|
||||
description: {
|
||||
type: "string",
|
||||
example: "Gets active audio/visual records",
|
||||
description: "Short explanation of what this query does",
|
||||
},
|
||||
options: {
|
||||
type: "string",
|
||||
example: "foo,baz",
|
||||
description:
|
||||
"Optional comma separated options string passed to the query",
|
||||
},
|
||||
publicAccess: {
|
||||
type: "boolean",
|
||||
example: "true",
|
||||
description:
|
||||
"Will this query be accessible by the frontend's",
|
||||
},
|
||||
queryFile: {
|
||||
type: "string",
|
||||
format: "binary",
|
||||
description: "SQL file containing the query text",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
"200": {
|
||||
description: "Query successfully created",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: { type: "boolean", example: true },
|
||||
message: {
|
||||
type: "string",
|
||||
example: "active_av was just added",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"400": {
|
||||
description: "Validation or input error",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: { type: "boolean", example: false },
|
||||
message: {
|
||||
type: "string",
|
||||
example: "Validation failed",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
81
backend/scaler/datamartUpdate.spec.ts
Normal file
81
backend/scaler/datamartUpdate.spec.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import type { OpenAPIV3_1 } from "openapi-types";
|
||||
|
||||
export const datamartUpdateSpec: OpenAPIV3_1.PathsObject = {
|
||||
"/api/datamart": {
|
||||
patch: {
|
||||
summary: "Update datamart query",
|
||||
description:
|
||||
"Update query entry in the datamart. Must be called on the main server. The SQL must be provided as a file upload.",
|
||||
tags: ["Datamart"],
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
"multipart/form-data": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
name: {
|
||||
type: "string",
|
||||
example: "active_av",
|
||||
description: "Unique name for the query",
|
||||
},
|
||||
description: {
|
||||
type: "string",
|
||||
example: "Gets active articles",
|
||||
description: "Short explanation of what this query does",
|
||||
},
|
||||
options: {
|
||||
type: "string",
|
||||
example: "foo,baz",
|
||||
description:
|
||||
"Optional comma separated options string passed to the query",
|
||||
},
|
||||
queryFile: {
|
||||
type: "string",
|
||||
format: "binary",
|
||||
description: "SQL file containing the query text",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
"200": {
|
||||
description: "Query successfully created",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: { type: "boolean", example: true },
|
||||
message: {
|
||||
type: "string",
|
||||
example: "active_av was just added",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"400": {
|
||||
description: "Validation or input error",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: { type: "boolean", example: false },
|
||||
message: {
|
||||
type: "string",
|
||||
example: "Validation failed",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
77
backend/scaler/getDatamart.spec.ts
Normal file
77
backend/scaler/getDatamart.spec.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import type { OpenAPIV3_1 } from "openapi-types";
|
||||
|
||||
export const getDatamartSpec: OpenAPIV3_1.PathsObject = {
|
||||
"/api/datamart/{name}": {
|
||||
get: {
|
||||
summary: "Runs the query by name",
|
||||
description:
|
||||
"This will allow to run any query by its name and optional parameters to be sent over as well, up to 3 params can be added",
|
||||
tags: ["Datamart"],
|
||||
|
||||
parameters: [
|
||||
{
|
||||
name: "name",
|
||||
in: "path",
|
||||
required: false,
|
||||
description: "Name to look up",
|
||||
schema: {
|
||||
type: "string",
|
||||
},
|
||||
example: "exampleName",
|
||||
},
|
||||
{
|
||||
name: "limit",
|
||||
in: "query",
|
||||
required: false, // 👈 optional
|
||||
description: "Maximum number of records to return",
|
||||
schema: {
|
||||
type: "integer",
|
||||
minimum: 1,
|
||||
maximum: 100,
|
||||
},
|
||||
example: 10,
|
||||
},
|
||||
],
|
||||
|
||||
responses: {
|
||||
"200": {
|
||||
description: "Successful response",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: { type: "boolean", example: true },
|
||||
data: {
|
||||
type: "object",
|
||||
example: {
|
||||
name: "exampleName",
|
||||
value: "some value",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"400": {
|
||||
description: "Bad request",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: { type: "boolean", example: false },
|
||||
message: {
|
||||
type: "string",
|
||||
example: "Invalid name parameter",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
122
backend/scaler/login.spec.ts
Normal file
122
backend/scaler/login.spec.ts
Normal file
@@ -0,0 +1,122 @@
|
||||
import type { OpenAPIV3_1 } from "openapi-types";
|
||||
|
||||
export const prodLoginSpec: OpenAPIV3_1.PathsObject = {
|
||||
"/api/authentication/login": {
|
||||
post: {
|
||||
summary: "Login",
|
||||
description:
|
||||
"Allows login by username and password and returns the user object to get the session data.",
|
||||
tags: ["Auth"],
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
required: ["username", "password"],
|
||||
properties: {
|
||||
username: {
|
||||
type: "string",
|
||||
example: "jdoe",
|
||||
},
|
||||
password: {
|
||||
type: "string",
|
||||
format: "password",
|
||||
example: "superSecretPassword",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
"200": {
|
||||
description: "User info",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: {
|
||||
type: "boolean",
|
||||
|
||||
example: true,
|
||||
},
|
||||
message: {
|
||||
type: "string",
|
||||
example: "Welcome back jdoe123",
|
||||
},
|
||||
level: {
|
||||
type: "string",
|
||||
},
|
||||
module: {
|
||||
type: "string",
|
||||
},
|
||||
subModule: {
|
||||
type: "string",
|
||||
},
|
||||
data: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
redirect: { type: "boolean" },
|
||||
token: { type: "string" },
|
||||
user: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "string" },
|
||||
name: { type: "string" },
|
||||
email: { type: "string", format: "email" },
|
||||
username: { type: "string" },
|
||||
role: { type: "string" },
|
||||
createdAt: { type: "string", format: "date-time" },
|
||||
updatedAt: { type: "string", format: "date-time" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"401": {
|
||||
description: "Login failed",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: {
|
||||
type: "boolean",
|
||||
|
||||
example: false,
|
||||
},
|
||||
message: {
|
||||
type: "string",
|
||||
example:
|
||||
"jdoe1234 dose not appear to be a valid username please try again",
|
||||
},
|
||||
level: {
|
||||
type: "string",
|
||||
example: "error",
|
||||
},
|
||||
module: {
|
||||
type: "string",
|
||||
example: "routes",
|
||||
},
|
||||
subModule: {
|
||||
type: "string",
|
||||
example: "auth",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
34
backend/scaler/prodSqlRestart.spec.ts
Normal file
34
backend/scaler/prodSqlRestart.spec.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { OpenAPIV3_1 } from "openapi-types";
|
||||
|
||||
export const prodRestartSpec: OpenAPIV3_1.PathsObject = {
|
||||
"/api/system/prodSql/restart": {
|
||||
post: {
|
||||
summary: "Prod restart sql connection",
|
||||
description: "Attempts to restart the sql connection.",
|
||||
tags: ["System"],
|
||||
responses: {
|
||||
"200": {
|
||||
description: "Success from server restarting",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: {
|
||||
type: "boolean",
|
||||
format: "true",
|
||||
example: true,
|
||||
},
|
||||
message: {
|
||||
type: "string",
|
||||
format: "Sql Server has been restarted",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
55
backend/scaler/prodSqlStart.spec.ts
Normal file
55
backend/scaler/prodSqlStart.spec.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import type { OpenAPIV3_1 } from "openapi-types";
|
||||
|
||||
export const prodStartSpec: OpenAPIV3_1.PathsObject = {
|
||||
"/api/system/prodSql/start": {
|
||||
post: {
|
||||
summary: "Prod start sql connection",
|
||||
description: "Connects to the prod sql server.",
|
||||
tags: ["System"],
|
||||
responses: {
|
||||
"200": {
|
||||
description: "Data that is returned from the connection",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: {
|
||||
type: "boolean",
|
||||
format: "true",
|
||||
example: true,
|
||||
},
|
||||
message: {
|
||||
type: "string",
|
||||
format: "usmcd1vms036 is connected to AlplaPROD_test3_cus",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"400": {
|
||||
description: "Data that is returned from the connection",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: {
|
||||
type: "boolean",
|
||||
format: "false",
|
||||
example: false,
|
||||
},
|
||||
message: {
|
||||
type: "string",
|
||||
format: "The Sql server is already connected.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
56
backend/scaler/prodSqlStop.spec.ts
Normal file
56
backend/scaler/prodSqlStop.spec.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import type { OpenAPIV3_1 } from "openapi-types";
|
||||
|
||||
export const prodStopSpec: OpenAPIV3_1.PathsObject = {
|
||||
"/api/system/prodSql/stop": {
|
||||
post: {
|
||||
summary: "Prod stop sql connection",
|
||||
description: "Closes the connection to the prod server.",
|
||||
tags: ["System"],
|
||||
responses: {
|
||||
"200": {
|
||||
description: "Success from server starting",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: {
|
||||
type: "boolean",
|
||||
format: "true",
|
||||
example: true,
|
||||
},
|
||||
message: {
|
||||
type: "string",
|
||||
format: "The sql connection has been closed.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"400": {
|
||||
description: "Errors on why the server could not be stopped",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: {
|
||||
type: "boolean",
|
||||
format: "false",
|
||||
example: false,
|
||||
},
|
||||
message: {
|
||||
type: "string",
|
||||
format:
|
||||
"There is no connection to the prod server currently.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
87
backend/scaler/register.spec.ts
Normal file
87
backend/scaler/register.spec.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import type { OpenAPIV3_1 } from "openapi-types";
|
||||
|
||||
export const prodRegisterSpec: OpenAPIV3_1.PathsObject = {
|
||||
"/api/authentication/register": {
|
||||
post: {
|
||||
summary: "Register",
|
||||
description: "Registers a new user.",
|
||||
tags: ["Auth"],
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
required: ["username", "password", "email"],
|
||||
properties: {
|
||||
username: {
|
||||
type: "string",
|
||||
example: "jdoe",
|
||||
},
|
||||
name: {
|
||||
type: "string",
|
||||
format: "string",
|
||||
example: "joe",
|
||||
},
|
||||
email: {
|
||||
type: "string",
|
||||
format: "email",
|
||||
example: "joe.doe@alpla.net",
|
||||
},
|
||||
password: {
|
||||
type: "string",
|
||||
format: "password",
|
||||
example: "superSecretPassword",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
"200": {
|
||||
description: "User info",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: {
|
||||
type: "boolean",
|
||||
format: "true",
|
||||
example: true,
|
||||
},
|
||||
message: {
|
||||
type: "string",
|
||||
example: "User was created",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"400": {
|
||||
description: "Invalid Data was sent over",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: {
|
||||
type: "boolean",
|
||||
format: "false",
|
||||
example: false,
|
||||
},
|
||||
message: {
|
||||
type: "string",
|
||||
format: "Invalid Data was sent over.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
43
backend/scaler/stats.spec.ts
Normal file
43
backend/scaler/stats.spec.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import type { OpenAPIV3_1 } from "openapi-types";
|
||||
|
||||
export const statusSpec: OpenAPIV3_1.PathsObject = {
|
||||
"/api/stats": {
|
||||
get: {
|
||||
summary: "Server Status",
|
||||
description: "Checks the status of the server.",
|
||||
tags: ["System"],
|
||||
responses: {
|
||||
"200": {
|
||||
description: "Stats from the server",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
status: {
|
||||
type: "string",
|
||||
format: "ok",
|
||||
example: "ok",
|
||||
},
|
||||
uptime: {
|
||||
type: "number",
|
||||
format: "3454.34",
|
||||
example: 3454.34,
|
||||
},
|
||||
memoryUsage: {
|
||||
type: "string",
|
||||
format: "Heap: 11.62 MB / RSS: 86.31 MB",
|
||||
},
|
||||
sqlServerStats: {
|
||||
type: "number",
|
||||
format: "442127",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user