Skip to content

Commit

Permalink
Merge pull request #343 from VinayJariya/fixed-full-status-endpoint
Browse files Browse the repository at this point in the history
fix: updated the full-status api to use swagger spec for counts
  • Loading branch information
ageddesi committed Jun 13, 2023
2 parents a7d8c7f + eb75fb1 commit 8b2d96d
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 17 deletions.
8 changes: 4 additions & 4 deletions api/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('dotenv').config();
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';
Expand Down Expand Up @@ -40,9 +40,9 @@ app.get('/full-status', (req, res) => {
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,
totalEndpoints: Object.keys(swaggerSpec['paths']).length,
version: swaggerSpec['info']['version'],
};
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
Expand Up @@ -42,10 +42,18 @@ const options: swaggerJsdoc.Options = {
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 @@ const options: swaggerJsdoc.Options = {
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 @@ const options: swaggerJsdoc.Options = {
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 @@ const options: swaggerJsdoc.Options = {
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 @@ const options: swaggerJsdoc.Options = {
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

0 comments on commit 8b2d96d

Please sign in to comment.