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: swagger docs routing #361

Merged
merged 2 commits into from
Oct 16, 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
2 changes: 1 addition & 1 deletion api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ SENTRY_DSN=https://23423423.ingest.sentry.io/234234
ENABLE_SENTRY=false
ENABLE_RATE_LIMIT=false
ENABLE_MORGAN_LOGGING=false
ENABLE_SWAGGER=false
ENABLE_SWAGGER=true
8 changes: 7 additions & 1 deletion 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 { 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,15 +40,21 @@
uptime: process.uptime(),
message: 'Ok',
date: new Date(),
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);
});

app.use(cors()); // enabling CORS for all requests;

if (process.env.ENABLE_SWAGGER === 'true') initSwagger(app); // setup Swagger;
if (process.env.ENABLE_SWAGGER === 'true'){
initSwagger(app); // setup Swagger;
} else {
app.get('/', (req, res) => {
res.status(200).send('Welcome to the Mocked API')
})
}

export default app;
Loading