Skip to content

Commit

Permalink
Formating and details on swagger page
Browse files Browse the repository at this point in the history
  • Loading branch information
Its4Nik committed Nov 1, 2024
1 parent 68bb589 commit 6123267
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 100 deletions.
38 changes: 19 additions & 19 deletions config/db.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
const sqlite3 = require('sqlite3').verbose();
const logger = require('./../utils/logger');
const path = require('path');
const dbPath = path.join(__dirname, '../data/database.db');

const db = new sqlite3.Database(dbPath, (err) => {
if (err) {
logger.error('Error opening database:', err.message);
} else {
db.run(`CREATE TABLE IF NOT EXISTS data (
id INTEGER PRIMARY KEY AUTOINCREMENT,
info TEXT NOT NULL,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
)`);
logger.info('Database created / opened succesfully');
}
});

module.exports = db;
const sqlite3 = require("sqlite3").verbose();
const logger = require("./../utils/logger");
const path = require("path");
const dbPath = path.join(__dirname, "../data/database.db");

const db = new sqlite3.Database(dbPath, (err) => {
if (err) {
logger.error("Error opening database:", err.message);
} else {
db.run(`CREATE TABLE IF NOT EXISTS data (
id INTEGER PRIMARY KEY AUTOINCREMENT,
info TEXT NOT NULL,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
)`);
logger.info("Database created / opened succesfully");
}
});

module.exports = db;
35 changes: 19 additions & 16 deletions config/loggerConfig.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
const { format } = require('winston');

module.exports = {
level: 'info',
format: format.combine(
format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
format.printf(({ timestamp, level, message }) => `${timestamp} [${level.toUpperCase()}]: ${message}`)
),
transports: {
console: true,
file: {
enabled: true,
filename: 'logs/app.log',
},
},
};
const { format } = require("winston");

module.exports = {
level: "info",
format: format.combine(
format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
format.printf(
({ timestamp, level, message }) =>
`${timestamp} [${level.toUpperCase()}]: ${message}`,
),
),
transports: {
console: true,
file: {
enabled: true,
filename: "logs/app.log",
},
},
};
57 changes: 29 additions & 28 deletions config/swaggerConfig.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
const options = {
definition: {
openapi: '3.0.0',
info: {
title: 'Your API Documentation',
version: '1.0.0',
description: 'API documentation with authentication',
},
components: {
securitySchemes: {
passwordAuth: {
type: 'apiKey',
in: 'header',
name: 'x-password',
description: 'Password required for authentication',
},
},
},
security: [
{
passwordAuth: [],
},
],
},
apis: ['./routes/*/*.js'], // Point to your route files
};

module.exports = options;
const options = {
definition: {
failOnErrors: true,
openapi: "3.0.0",
info: {
title: "DockStatAPI",
version: "2",
description: "An API used to query muliple docker hosts",
},
components: {
securitySchemes: {
passwordAuth: {
type: "apiKey",
in: "header",
name: "x-password",
description: "Password required for authentication",
},
},
},
security: [
{
passwordAuth: [],
},
],
},
apis: ["./routes/*/*.js"],
};

module.exports = options;
Binary file modified data/database.db
Binary file not shown.
70 changes: 35 additions & 35 deletions misc/dependencyGraphs/mermaid-all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,33 @@ end
subgraph 5["utils"]
6["dockerClient.js"]
8["containerService.js"]
N["extractHostData.js"]
O["writeOfflineLog.js"]
U["rateLimiter.js"]
O["extractHostData.js"]
P["writeOfflineLog.js"]
end
subgraph C["middleware"]
D["authMiddleware.js"]
E["rateLimiter.js"]
end
subgraph E["routes"]
subgraph F["auth"]
G["routes.js"]
subgraph F["routes"]
subgraph G["auth"]
H["routes.js"]
end
subgraph H["data"]
I["routes.js"]
subgraph I["data"]
J["routes.js"]
end
subgraph J["frontendController"]
K["routes.js"]
subgraph K["frontendController"]
L["routes.js"]
end
subgraph L["getter"]
M["routes.js"]
subgraph M["getter"]
N["routes.js"]
end
subgraph P["setter"]
Q["routes.js"]
subgraph Q["setter"]
R["routes.js"]
end
end
R["server.js"]
subgraph S["swagger"]
T["swaggerDocs.js"]
S["server.js"]
subgraph T["swagger"]
U["swaggerDocs.js"]
end
4-->6
7-->1
Expand All @@ -49,22 +49,22 @@ end
8-->6
B-->1
B-->7
I-->1
K-->A
M-->9
M-->B
M-->8
M-->6
M-->N
M-->O
Q-->B
J-->1
L-->A
N-->9
N-->B
N-->8
N-->6
N-->O
N-->P
R-->B
R-->D
R-->G
R-->I
R-->K
R-->M
R-->Q
R-->T
R-->U
T-->2
S-->B
S-->D
S-->E
S-->H
S-->J
S-->L
S-->N
S-->R
S-->U
U-->2
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dockstatapi",
"version": "1.0.0",
"version": "2",
"description": "API for docker hosts using dockerode",
"main": "server.js",
"scripts": {
Expand All @@ -11,7 +11,7 @@
},
"keywords": [],
"author": "Its4Nik",
"license": "ISC",
"license": "BSD 3-Clause License",
"dependencies": {
"bcrypt": "^5.1.1",
"child_process": "^1.0.2",
Expand Down

0 comments on commit 6123267

Please sign in to comment.