index.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. host: 'localhost',
  49. charset: 'utf8_general_ci',
  50. user: 'root',
  51. password: 'admin'
  52. },
  53. mongodb: {},
  54. sqlite: {},
  55. api: {
  56. prefix: '/api',
  57. },
  58. emails: {
  59. apiKey: process.env.MAILGUN_API_KEY,
  60. domain: process.env.MAILGUN_DOMAIN
  61. }
  62. }