mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 11:29:42 +00:00
Initialize Swagger in dev, document /login1 for demonstration
This commit is contained in:
+36
-7
@@ -4,9 +4,11 @@ import cors from 'cors';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import mongoose from 'mongoose';
|
||||
import dotenv from 'dotenv';
|
||||
import swaggerJSDoc from 'swagger-jsdoc';
|
||||
import swaggerUi from 'swagger-ui-express';
|
||||
|
||||
dotenv.config();
|
||||
import * as Sentry from '@sentry/node';
|
||||
// import { PostHogClient } from './services';
|
||||
import { PORT, SENTRY_DSN, NODE_ENV, MONGO_URL, SITE_URL, POSTHOG_PROJECT_API_KEY, POSTHOG_HOST, TELEMETRY_ENABLED } from './config';
|
||||
import { apiLimiter } from './helpers/rateLimiter';
|
||||
|
||||
@@ -19,12 +21,6 @@ Sentry.init({
|
||||
environment: NODE_ENV
|
||||
});
|
||||
|
||||
// PostHogClient.init({
|
||||
// projectApiKey: POSTHOG_PROJECT_API_KEY,
|
||||
// host: POSTHOG_HOST,
|
||||
// telemetryEnabled: TELEMETRY_ENABLED
|
||||
// });
|
||||
|
||||
import {
|
||||
signup as signupRouter,
|
||||
auth as authRouter,
|
||||
@@ -72,6 +68,39 @@ if (NODE_ENV === 'production') {
|
||||
app.use(helmet());
|
||||
}
|
||||
|
||||
if (NODE_ENV === 'development') {
|
||||
const swaggerDefinition = {
|
||||
openapi: '3.0.0',
|
||||
info: {
|
||||
title: 'Infisical API',
|
||||
version: '1.0.0',
|
||||
description: 'Infisical is an open-source, E2EE tool to sync environment variables across your team and infrastructure.',
|
||||
license: {
|
||||
name: 'License',
|
||||
url: 'https://github.com/Infisical/infisical/blob/main/LICENSE'
|
||||
},
|
||||
contact: {
|
||||
name: 'Infisical',
|
||||
url: 'https://infisical.com'
|
||||
},
|
||||
},
|
||||
servers: [
|
||||
{
|
||||
url: 'http://localhost:8080/api/v1',
|
||||
description: 'Development server'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const options = {
|
||||
swaggerDefinition,
|
||||
apis: ['./src/routes/*.ts']
|
||||
}
|
||||
|
||||
const swaggerSpec = swaggerJSDoc(options);
|
||||
app.use('/api/docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
|
||||
}
|
||||
|
||||
app.use(express.json());
|
||||
|
||||
// routers
|
||||
|
||||
Reference in New Issue
Block a user