index.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import * as dotenv from 'dotenv';
  2. process.env.NODE_ENV = process.env.NODE_ENV || 'development';
  3. const envFound = dotenv.config();
  4. if (envFound.error) {
  5. throw new Error("⚠️ Couldn't find .env file ⚠️");
  6. }
  7. export default {
  8. port: parseInt(process.env.PORT, 10),
  9. databaseURL: process.env.MONGODB_URI,
  10. jwtSecret: process.env.JWT_SECRET,
  11. jwtAlgorithm: process.env.JWT_ALGO,
  12. options: {
  13. swaggerDefinition: {
  14. info: {
  15. description: 'This is a server',
  16. title: 'Swagger',
  17. version: '1.0.0'
  18. },
  19. host: `localhost:${parseInt(process.env.PORT, 10)}`,
  20. basePath: '/',
  21. produces: ['application/json', 'application/xml'],
  22. schemes: ['http', 'https'],
  23. securityDefinitions: {
  24. JWT: {
  25. type: 'apiKey',
  26. in: 'header',
  27. name: 'Authorization',
  28. description: ''
  29. }
  30. }
  31. },
  32. route: {
  33. url: './swagger-ui.html',
  34. docs: '/swagger.json' //swagger文件 api
  35. },
  36. basedir: __dirname, //app absolute path
  37. files: ['../router/api/*.ts'] //Path to the API handle folder
  38. },
  39. logs: {
  40. level: process.env.LOG_LEVEL || 'silly',
  41. },
  42. agenda: {
  43. dbCollection: process.env.AGENDA_DB_COLLECTION,
  44. pooltime: process.env.AGENDA_POOL_TIME,
  45. concurrency: parseInt(process.env.AGENDA_CONCURRENCY, 10),
  46. },
  47. mysql: {
  48. user: 'admin',
  49. password: '123456'
  50. },
  51. api: {
  52. prefix: '/api',
  53. },
  54. emails: {
  55. apiKey: process.env.MAILGUN_API_KEY,
  56. domain: process.env.MAILGUN_DOMAIN
  57. }
  58. };