Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: updated the full-status api to use swagger spec for counts #343

Merged
merged 3 commits into from
Jun 13, 2023
Merged
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
8 changes: 4 additions & 4 deletions api/app.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require('dotenv').config();

Check warning on line 1 in api/app.ts

View check run for this annotation

Codeac.io / Codeac Code Quality

no-var-requires

require statement not part of an import statement
import express, { Request, Response } from 'express';
import swag from './swagger.json';
import { swaggerSpec } from './src/utils/swagger';
import { applicationRateLimiter } from './middleware/rate-limiter/RateLimiter';
import { initSwagger } from './src/setup/swagger';
import { initSentry } from './src/setup/sentry';
import path from 'path';
const morgan = require('morgan');

Check warning on line 8 in api/app.ts

View check run for this annotation

Codeac.io / Codeac Code Quality

no-var-requires

require statement not part of an import statement
const cors = require('cors');

Check warning on line 9 in api/app.ts

View check run for this annotation

Codeac.io / Codeac Code Quality

no-var-requires

require statement not part of an import statement
const fs = require('fs');

Check warning on line 10 in api/app.ts

View check run for this annotation

Codeac.io / Codeac Code Quality

no-var-requires

require statement not part of an import statement
const app = express();

const constantPath = './src/modules/';
Expand Down Expand Up @@ -40,9 +40,9 @@
uptime: process.uptime(),
message: 'Ok',
date: new Date(),
totalCategories: swag.tags.length,
totalEndpoints: Object.keys(swag.paths).length,
version: swag.info.version,
totalCategories: swaggerSpec['tags'].length,

Check warning on line 43 in api/app.ts

View check run for this annotation

Codeac.io / Codeac Code Quality

no-string-literal

object access via string literals is disallowed
totalEndpoints: Object.keys(swaggerSpec['paths']).length,

Check warning on line 44 in api/app.ts

View check run for this annotation

Codeac.io / Codeac Code Quality

no-string-literal

object access via string literals is disallowed
version: swaggerSpec['info']['version'],

Check warning on line 45 in api/app.ts

View check run for this annotation

Codeac.io / Codeac Code Quality

no-string-literal

object access via string literals is disallowed

Check warning on line 45 in api/app.ts

View check run for this annotation

Codeac.io / Codeac Code Quality

no-string-literal

object access via string literals is disallowed
};
res.status(200).send(data);
});
Expand Down
40 changes: 32 additions & 8 deletions api/src/utils/swagger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import swaggerJsdoc from 'swagger-jsdoc';

const { version } = require('../../package.json');

Check warning on line 3 in api/src/utils/swagger.ts

View check run for this annotation

Codeac.io / Codeac Code Quality

no-var-requires

require statement not part of an import statement

const options: swaggerJsdoc.Options = {
definition: {
Expand Down Expand Up @@ -42,10 +42,18 @@
name: 'Colors',
description: 'A set of endpoints related to colors',
},
{
name: 'Coordinates',
description: 'A set of endpoints to obtain random coordinates',
},
{
name: 'Countries',
description: 'A set of endpoints related to countries',
},
{
name: 'Courses',
description: 'A set of endpoints related to Courses',
},
{
name: 'Currencies',
description: 'A set of endpoints related to currencies',
Expand All @@ -54,10 +62,6 @@
name: 'Ecommerce',
description: 'A set of endpoints related to ecommerce',
},
{
name: 'Courses',
description: 'A set of endpoints related to Courses',
},
{
name: 'Elements',
description: 'A set of endpoints related to elements on the periodic table',
Expand All @@ -75,13 +79,21 @@
description: 'A set of endpoints related to obtaining placeholder image urls',
},
{
name: 'IPs',
description: 'A set of endpoints related to obtaining random IP Addresses',
name: 'Instruments',
description: 'A set of endpoints related to instruments',
},
{
name: 'Invoices',
description: 'A set of endpoints related to invoices',
},
{
name: 'IPs',
description: 'A set of endpoints related to obtaining random IP Addresses',
},
{
name: 'Movies',
description: 'A set of endpoints related to get movies',
},
{
name: 'Music',
description: 'A set of endpoints related to music',
Expand All @@ -91,8 +103,12 @@
description: 'A set of endpoints to get randomly generated names',
},
{
name: 'PhoneNumbers',
description: 'A set of endpoints to get randomly generated phone numbers',
name: 'News',
description: 'A set of endpoints to get news',
},
{
name: 'Phone Numbers',
description: 'A set of endpoints to get random phone numbers',
},
{
name: 'Products',
Expand Down Expand Up @@ -122,6 +138,14 @@
name: 'Users',
description: 'A set of endpoints to get random user data',
},
{
name: 'Vehicles',
description: 'A set of endpoints to obtain vehicles',
},
{
name: 'Video',
description: 'A set of endpoints to obtain random video data',
},
{
name: 'Weathers',
description: 'A set of endpoints to get random weather data',
Expand Down
66 changes: 61 additions & 5 deletions api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,42 @@
"application/json"
],
"tags": [
{
"name": "Address",
"description": "A set of endpoints related to addresses"
},
{
"name": "Animals",
"description": "A set of endpoints related to animal"
},
{
"name": "Banks",
"description": "A set of endpoints related to bank feeds"
},
{
"name": "Chat",
"description": "A set of endpoints related to chats"
},
{
"name": "Chuck Norris",
"description": "A set of endpoints related to Chuck Norris Facts"
},
{
"name": "Colors",
"description": "A set of endpoints related to colors"
},
{
"name": "Coordinates",
"description": "A set of endpoints to obtain random coordinates"
},
{
"name": "Countries",
"description": "A set of endpoints related to countries"
},
{
"name": "Courses",
"description": "A set of endpoints related to Courses"
},
{
"name": "Currencies",
"description": "A set of endpoints related to currencies"
Expand All @@ -41,18 +61,38 @@
"name": "Ecommerce",
"description": "A set of endpoints related to ecommerce"
},
{
"name": "Elements",
"description": "A set of endpoints related to elements on the periodic table"
},
{
"name": "Emails",
"description": "A set of endpoints related to emails"
},
{
"name": "Food",
"description": "A set of endpoints related to food"
},
{
"name": "Images",
"description": "A set of endpoints related to obtaining placeholder image urls"
},
{
"name": "Instruments",
"description": "A set of endpoints related to instruments"
},
{
"name": "Invoices",
"description": "A set of endpoints related to invoices"
},
{
"name": "IPs",
"description": "A set of endpoints related to obtaining random IP Addresses"
},
{
"name": "Movies",
"description": "A set of endpoints related to get movies"
},
{
"name": "Music",
"description": "A set of endpoints related to music"
Expand All @@ -61,6 +101,10 @@
"name": "Names",
"description": "A set of endpoints to get randomly generated names"
},
{
"name": "News",
"description": "A set of endpoints to get news"
},
{
"name": "Phone Numbers",
"description": "A set of endpoints to get random phone numbers"
Expand All @@ -82,16 +126,28 @@
"description": "A set of endpoints to get random sports data"
},
{
"name": "Chemical Elements",
"description": "A set of endpoints to get random Chemical Elements values"
"name": "Text",
"description": "A set of endpoints to get random text"
},
{
"name": "TimeZones",
"description": "A set of endpoints related to TimeZones"
"description": "A set of endpoints to get random time zones"
},
{
"name": "Users",
"description": "A set of endpoints to get random user data"
},
{
"name": "Vehicles",
"description": "A set of endpoints to obtain vehicles"
},
{
"name": "Video",
"description": "A set of endpoints to obtain random video data"
},
{
"name": "IP",
"description": "A set of endpoints to get random ip and mac address"
"name": "Weathers",
"description": "A set of endpoints to get random weather data"
}
],
"paths": {
Expand Down
Loading