server-config.ts 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. const Config = {
  2. limits: {
  3. /**
  4. * Maximum number of blocks that could be read in 1 query.
  5. * This is somewhat tied to the maxOutputSizeInVoxelCountByPrecisionLevel
  6. * in that the <maximum number of voxel> = maxRequestBlockCount * <block size>^3.
  7. * The default block size is 96 which corresponds to 28,311,552 voxels with 32 max blocks.
  8. */
  9. maxRequestBlockCount: 32,
  10. /**
  11. * The maximum fractional volume of the query box (to prevent queries that are too big).
  12. */
  13. maxFractionalBoxVolume: 1024,
  14. /**
  15. * What is the (approximate) maximum desired size in voxel count by precision level
  16. * Rule of thumb: <response gzipped size> \in [<voxel count> / 8, <voxel count> / 4];
  17. *
  18. * The maximum number of voxels is tied to maxRequestBlockCount.
  19. */
  20. maxOutputSizeInVoxelCountByPrecisionLevel: [
  21. 0.5 * 1024 * 1024, // ~ 80*80*80
  22. 1 * 1024 * 1024,
  23. 2 * 1024 * 1024,
  24. 4 * 1024 * 1024,
  25. 8 * 1024 * 1024,
  26. 16 * 1024 * 1024, // ~ 256*256*256
  27. 24 * 1024 * 1024
  28. ]
  29. },
  30. /**
  31. * Specify the prefix of the API, i.e.
  32. * <host>/<apiPrefix>/<API queries>
  33. */
  34. apiPrefix: '/VolumeServer',
  35. /**
  36. * If not specified otherwise by the 'port' environment variable, use this port.
  37. */
  38. defaultPort: 1337,
  39. /**
  40. * Node (V8) sometimes exhibits GC related issues that significantly slow down the execution
  41. * (https://github.com/nodejs/node/issues/8670).
  42. *
  43. * Therefore an option is provided that automatically shuts down the server.
  44. * For this to work, the server must be run using a deamon (i.e. forever.js on Linux
  45. * or IISnode on Windows) so that the server is automatically restarted when the shutdown happens.
  46. */
  47. shutdownParams: {
  48. // 0 for off, server will shut down after this amount of minutes.
  49. timeoutMinutes: 24 * 60 /* a day */,
  50. // modifies the shutdown timer by +/- timeoutVarianceMinutes (to avoid multiple instances shutting at the same time)
  51. timeoutVarianceMinutes: 60
  52. },
  53. /**
  54. * Maps a request identifier to a filename.
  55. *
  56. * @param source
  57. * Source of the data.
  58. * @param id
  59. * Id provided in the request. For xray, PDB id, for emd, EMDB id number.
  60. */
  61. mapFile(source: string, id: string) {
  62. switch (source.toLowerCase()) {
  63. case 'x-ray': return `g:/test/mdb/xray-${id.toLowerCase()}.mdb`;
  64. case 'emd': return `g:/test/mdb/${id.toLowerCase()}.mdb`;
  65. default: return void 0;
  66. }
  67. }
  68. }
  69. export default Config;