test(datamart): more work on datamart stuff
This commit is contained in:
@@ -8,9 +8,13 @@ import type { Express } from "express";
|
||||
import { apiReference } from "@scalar/express-api-reference";
|
||||
// const port = 3000;
|
||||
import type { OpenAPIV3_1 } from "openapi-types";
|
||||
import { datamartAddSpec } from "../scaler/datamartAdd.spec.js";
|
||||
import { getDatamartSpec } from "../scaler/getDatamart.spec.js";
|
||||
import { prodLoginSpec } from "../scaler/login.spec.js";
|
||||
import { prodRestartSpec } from "../scaler/prodSqlRestart.spec.js";
|
||||
import { prodStartSpec } from "../scaler/prodSqlStart.spec.js";
|
||||
import { prodStopSpec } from "../scaler/prodSqlStop.spec.js";
|
||||
import { prodRegisterSpec } from "../scaler/register.spec.js";
|
||||
// all the specs
|
||||
import { statusSpec } from "../scaler/stats.spec.js";
|
||||
|
||||
@@ -62,6 +66,10 @@ export const setupApiDocsRoutes = (baseUrl: string, app: Express) => {
|
||||
...prodStartSpec,
|
||||
...prodStopSpec,
|
||||
...prodRestartSpec,
|
||||
...prodLoginSpec,
|
||||
...prodRegisterSpec,
|
||||
...getDatamartSpec,
|
||||
...datamartAddSpec,
|
||||
|
||||
// Add more specs here as you build features
|
||||
},
|
||||
|
||||
@@ -4,10 +4,4 @@ export const setupDatamartRoutes = (baseUrl: string, app: Express) => {
|
||||
//setup all the routes
|
||||
|
||||
app.use(`${baseUrl}/api/datamart`, runQuery);
|
||||
|
||||
app.all("*foo", (_, res) => {
|
||||
res.status(400).json({
|
||||
message: "You have encountered a datamart route that dose not exist",
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
87
backend/src/scaler/datamartAdd.spec.ts
Normal file
87
backend/src/scaler/datamartAdd.spec.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import type { OpenAPIV3_1 } from "openapi-types";
|
||||
|
||||
export const datamartAddSpec: OpenAPIV3_1.PathsObject = {
|
||||
"/api/datamart/add": {
|
||||
post: {
|
||||
summary: "Creates the new query",
|
||||
description: "Queries can only be created on the main server.",
|
||||
tags: ["Datamart"],
|
||||
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.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
77
backend/src/scaler/getDatamart.spec.ts
Normal file
77
backend/src/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: true,
|
||||
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",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user