Skip to content

Commit 922949a

Browse files
fix issue where swagger was not resolving correctly in dev env (#1478)
| Before | After | | --- | --- | | <img width="824" height="151" alt="Screenshot 2025-12-12 at 1 17 28 PM" src="https://github.com/user-attachments/assets/44d0af8d-c1d4-4551-a38d-38c54c3eaf8e" /> | <img width="1544" height="634" alt="Screenshot 2025-12-12 at 1 16 38 PM" src="https://github.com/user-attachments/assets/93156104-c4e9-493b-abab-b80a60b2e00f" /> | | <img width="2328" height="538" alt="Screenshot 2025-12-12 at 1 17 19 PM" src="https://github.com/user-attachments/assets/4cac5d92-8155-46eb-9b15-399223b9d2fd" /> | No Output |
1 parent 780279f commit 922949a

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

packages/api/eslint.config.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ export default [
5050
varsIgnorePattern: '^_',
5151
},
5252
],
53+
'n/no-missing-require': [
54+
'error',
55+
{
56+
tryExtensions: ['.js', '.ts', '.json'],
57+
},
58+
],
5359
'n/no-process-exit': 'warn',
5460
'n/no-missing-import': 'off',
5561
'n/no-unpublished-import': [

packages/api/src/api-app.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import savedSearchRouter from './routers/api/savedSearch';
1515
import sourcesRouter from './routers/api/sources';
1616
import externalRoutersV2 from './routers/external-api/v2';
1717
import usageStats from './tasks/usageStats';
18-
import { expressLogger } from './utils/logger';
18+
import logger, { expressLogger } from './utils/logger';
1919
import passport from './utils/passport';
2020

2121
const app: express.Application = express();
@@ -105,17 +105,11 @@ if (
105105
process.env.NODE_ENV !== 'production' &&
106106
process.env.ENABLE_SWAGGER === 'true'
107107
) {
108-
import('./utils/swagger.js')
109-
.then(({ setupSwagger }) => {
110-
console.log('Swagger UI setup and available at /api/v2/docs');
111-
setupSwagger(app);
112-
})
113-
.catch(error => {
114-
console.error(
115-
'Failed to dynamically load or setup Swagger. Swagger UI will not be available.',
116-
error,
117-
);
118-
});
108+
// Will require a refactor to ESM to use import statements
109+
// eslint-disable-next-line @typescript-eslint/no-require-imports
110+
const { setupSwagger } = require('./utils/swagger');
111+
setupSwagger(app);
112+
logger.info('Swagger UI setup and available at /api/v2/docs');
119113
}
120114

121115
app.use('/api/v2', externalRoutersV2);

0 commit comments

Comments
 (0)