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

added the extra new values to the status endpoint. #191

Merged
merged 1 commit into from
Oct 11, 2022
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: 7 additions & 1 deletion app.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
require('dotenv').config();
import express, { Request, Response } from 'express';
import { swaggerSpec } from './utils/swagger';
import swag from "./swagger.json";

const morgan = require('morgan');
const cors = require('cors');

const app = express();

// Load Mock Modules
require('./modules/animal/api/animal-routes')(app); // Animals
require('./modules/chat/api/chat-routes')(app); // Chat
Expand All @@ -32,12 +34,16 @@ require('./modules/address/api/address-routes')(app); // Addresses
require('./modules/bankfeed/api/bankfeed-routes')(app); // Bank Feed
require('./modules/location/api/location-routes')(app); // Bank Feed


// Add an healthcheck endpoint
// Shows amount of API Categories and their endpoints
app.get('/status', (req, res) => {
const data = {
uptime: process.uptime(),
message: 'Ok',
date: new Date(),
totalCategories: swag.tags.length,
totalEndpoints: Object.keys(swag.paths).length,
};
res.status(200).send(data);
});
Expand All @@ -55,4 +61,4 @@ app.use('/', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
app.use(cors()); // enabling CORS for all requests
app.use(morgan('combined')); // adding morgan to log HTTP requests

export default app;
export default app;
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"module": "commonjs",
"target": "es6",
"rootDir": "./",
"esModuleInterop": true
"resolveJsonModule": true,
"esModuleInterop": true,
}
}