config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. 'use strict'
  2. import path from 'path'
  3. import winston from 'winston'
  4. export const PRODUCTION_MODE = process.env.NODE_ENV === 'production'
  5. export const TEST_MODE = process.env.NODE_ENV === 'test'
  6. // The url prefix for the API
  7. export const apiPrefix = '/api'
  8. // The url prefix from where the images are served
  9. export const imageServedUrl = apiPrefix + '/images'
  10. // The port used by the server
  11. export const serverPort = parseInt(process.env.PORT, 10) || 5000
  12. // The directory where the images are stored
  13. export const imagesPath = TEST_MODE
  14. ? path.resolve(__dirname, 'test', 'images') // Used for automated testing, don't touch
  15. : process.env.IMAGES_PATH || path.resolve(__dirname, 'images')
  16. // Should the server serve client files from the `/dist` directory
  17. export const serveClient = process.env.SERVE_CLIENT === 'true' || true
  18. // File name convention for images
  19. export const fileNameConvention = /^(.*)?_([0-9]{2,})\.(.*)$/
  20. // Name of the directory containing extracts
  21. export const extractsDirName = 'extracts'
  22. // Files to ignore in scenes
  23. export const sceneFileNameBlackList = ['config', 'seuilExpe', extractsDirName]
  24. // Logger configuration
  25. export const logger = winston.createLogger({
  26. level: 'info',
  27. format: winston.format.json(),
  28. transports: [
  29. new winston.transports.File({ filename: 'logs/server.combined.log' }),
  30. new winston.transports.File({ filename: 'logs/server.error.log', level: 'error' }),
  31. new winston.transports.Console({
  32. level: 'debug',
  33. handleExceptions: true,
  34. format: winston.format.simple()
  35. })
  36. ],
  37. exitOnError: false
  38. })
  39. // WebSocket logger configuration
  40. export const wsLogger = winston.createLogger({
  41. level: 'info',
  42. format: winston.format.json(),
  43. transports: [
  44. new winston.transports.File({ filename: 'logs/ws.log' }),
  45. new winston.transports.File({ filename: 'logs/ws.error.log', level: 'error' }),
  46. new winston.transports.Console({
  47. level: 'debug',
  48. handleExceptions: true,
  49. format: winston.format.simple()
  50. })
  51. ],
  52. exitOnError: false
  53. })