@k03mad/simple-prom 9.0.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/app/lib/server.js +14 -2
  2. package/package.json +1 -1
package/app/lib/server.js CHANGED
@@ -14,8 +14,9 @@ import {registerMetrics} from './register.js';
14
14
  * @param {object} opts.metrics
15
15
  * @param {string[]} opts.metricsTurnOff
16
16
  * @param {boolean} opts.debug
17
+ * @param {string} opts.static
17
18
  */
18
- export const startMetricsServer = ({appName, port, metrics, metricsTurnOff, debug}) => {
19
+ export const startMetricsServer = ({appName, port, metrics, metricsTurnOff, debug, static: staticOpts}) => {
19
20
  const register = registerMetrics({appName, port, metrics, metricsTurnOff});
20
21
 
21
22
  const app = express();
@@ -24,9 +25,20 @@ export const startMetricsServer = ({appName, port, metrics, metricsTurnOff, debu
24
25
  app.use(morgan('combined'));
25
26
  }
26
27
 
27
- app.use(helmet());
28
28
  app.use(compression());
29
29
 
30
+ if (staticOpts.folder) {
31
+ if (staticOpts.beforeHelmet) {
32
+ app.use(express.static(staticOpts.folder));
33
+ app.use(helmet());
34
+ } else {
35
+ app.use(helmet());
36
+ app.use(express.static(staticOpts.folder));
37
+ }
38
+ } else {
39
+ app.use(helmet());
40
+ }
41
+
30
42
  app.get('/metrics', async (req, res) => {
31
43
  const data = await register.metrics();
32
44
  res.send(data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k03mad/simple-prom",
3
- "version": "9.0.0",
3
+ "version": "9.2.0",
4
4
  "description": "Simple prom-client library",
5
5
  "maintainers": [
6
6
  "Kirill Molchanov <k03.mad@gmail.com"