server.ts 818 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { PlatformApplication } from '@tsed/common';
  2. import { Configuration, Inject } from '@tsed/di';
  3. import express from 'express';
  4. import '@tsed/swagger';
  5. import '@tsed/terminus';
  6. import * as Controllers from './controllers/index.js';
  7. import '@tsed/platform-express';
  8. const PORT = Number(process.env.PORT || 3010);
  9. @Configuration({
  10. port: PORT,
  11. acceptMimes: ['application/json'],
  12. mount: {
  13. '/': [...Object.values(Controllers)],
  14. },
  15. middlewares: [
  16. 'json-parser',
  17. express.json({ limit: '50mb' }),
  18. express.urlencoded({ extended: true, limit: '50mb' }),
  19. ],
  20. swagger: [
  21. {
  22. path: '/v3/docs',
  23. specVersion: '3.0.1',
  24. },
  25. ],
  26. terminus: {
  27. signals: ['SIGINT', 'SIGTERM'],
  28. },
  29. })
  30. class Server {
  31. @Inject()
  32. app: PlatformApplication | undefined;
  33. }
  34. export default Server;