Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"form-data": "^4.0.2",
"fs": "^0.0.1-security",
"http-errors": "^2.0.0",
"lodash": "^4.17.21",
"multer": "^1.4.5-lts.2",
"node-fetch": "^3.3.2",
"path": "^0.12.7",
Expand Down
263 changes: 261 additions & 2 deletions server/swagger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const swagger = {
{ name: "User", description: "User management" },
{ name: "Feature", description: "Feature management" },
{ name: "Bucket", description: "Bucket management" },
{ name: "Log", description: "Log management" },
{ name: "AlarmX", description: "AlarmX file processing" },
],
paths: {
"/auth/login": {
Expand Down Expand Up @@ -671,6 +673,231 @@ const swagger = {
},
},
},
"/log/create": {
post: {
tags: ["Log"],
operationId: "createLog",
summary: "Create a new log entry",
parameters: [],
requestBody: {
content: {
"application/json": {
schema: {
type: "object",
required: ["uid", "action", "target"],
properties: {
uid: {
type: "integer",
description: "User ID",
},
action: {
type: "string",
description: "Action performed",
},
target: {
type: "string",
description: "Target of the action",
},
details: {
type: "string",
description: "Additional details",
},
},
example: {
uid: 1,
action: "create",
target: "user",
details: "Created new user",
},
},
},
},
},
responses: {
200: {
description: "Success",
},
500: {
description: "Internal Server Error",
},
},
},
},
"/log/findByUserId/{uid}": {
get: {
tags: ["Log"],
operationId: "findLogsByUserId",
summary: "Find logs by user ID",
parameters: [
{
in: "path",
name: "uid",
description: "User ID",
required: true,
schema: {
type: "integer",
},
},
],
responses: {
200: {
description: "Success",
},
500: {
description: "Internal Server Error",
},
},
},
},
"/log/findById/{lid}": {
get: {
tags: ["Log"],
operationId: "findLogById",
summary: "Find log by log ID",
parameters: [
{
in: "path",
name: "lid",
description: "Log ID",
required: true,
schema: {
type: "integer",
},
},
],
responses: {
200: {
description: "Success",
},
500: {
description: "Internal Server Error",
},
},
},
},
"/log/findByAction": {
post: {
tags: ["Log"],
operationId: "findLogsByAction",
summary: "Find logs by action",
parameters: [],
requestBody: {
content: {
"application/json": {
schema: {
type: "object",
required: ["action"],
properties: {
action: {
type: "string",
description: "Action to filter by",
},
},
example: {
action: "create",
},
},
},
},
},
responses: {
200: {
description: "Success",
},
500: {
description: "Internal Server Error",
},
},
},
},
"/log/find": {
post: {
tags: ["Log"],
operationId: "findLogs",
summary: "Find logs by condition",
parameters: [],
requestBody: {
content: {
"application/json": {
schema: {
type: "object",
properties: {
condition: {
type: "object",
description: "Search condition object",
},
},
example: {
condition: {
action: "create",
target: "user",
},
},
},
},
},
},
responses: {
200: {
description: "Success",
},
500: {
description: "Internal Server Error",
},
},
},
},
"/alarmx/file/adibin": {
get: {
tags: ["AlarmX"],
operationId: "processAdibin",
summary: "Process ADIBIN file",
parameters: [
{
in: "query",
name: "filename",
description: "Name of the ADIBIN file to process",
required: true,
schema: {
type: "string",
},
},
{
in: "query",
name: "offset",
description: "Offset in seconds for reading the file",
required: true,
schema: {
type: "integer",
},
},
{
in: "query",
name: "range",
description: "Length in seconds of data to read",
required: true,
schema: {
type: "integer",
},
},
],
responses: {
200: {
description: "Success",
content: {
"text/plain": {
schema: {
type: "string",
},
},
},
},
500: {
description: "Internal Server Error",
},
},
},
},
},
components: {
schemas: {
Expand Down Expand Up @@ -761,6 +988,39 @@ const swagger = {
},
},
},
log: {
type: "object",
required: ["id", "action", "target", "userId"],
properties: {
id: {
type: "integer",
},
action: {
type: "string",
description: "Action performed",
},
target: {
type: "string",
description: "Target of the action",
},
details: {
type: "string",
description: "Additional details",
},
userId: {
type: "integer",
description: "User ID who performed the action",
},
createdAt: {
type: "string",
format: "date-time",
},
updatedAt: {
type: "string",
format: "date-time",
},
},
},
},
responses: {
UserArray: {
Expand Down Expand Up @@ -904,8 +1164,7 @@ const loadFeatures = () => {
if (featureData.components?.responses)
_.merge(swagger.components.responses, featureData.components.responses);
if (featureData.components?.requestBodies)
_.merge(swagger.components.requestBodies, featureData.components.request
);
_.merge(swagger.components.requestBodies, featureData.components.requestBodies);
}

return swagger;
Expand Down