@eik/core 1.3.54 → 1.3.55

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 (63) hide show
  1. package/lib/classes/alias.js +48 -48
  2. package/lib/classes/asset.js +99 -92
  3. package/lib/classes/author.js +20 -20
  4. package/lib/classes/http-incoming.js +52 -52
  5. package/lib/classes/http-outgoing.js +84 -83
  6. package/lib/classes/meta.js +20 -23
  7. package/lib/classes/package.js +73 -70
  8. package/lib/classes/versions.js +62 -60
  9. package/lib/handlers/alias.delete.js +125 -120
  10. package/lib/handlers/alias.get.js +92 -87
  11. package/lib/handlers/alias.post.js +196 -203
  12. package/lib/handlers/alias.put.js +196 -202
  13. package/lib/handlers/auth.post.js +95 -93
  14. package/lib/handlers/map.get.js +110 -111
  15. package/lib/handlers/map.put.js +256 -231
  16. package/lib/handlers/pkg.get.js +120 -122
  17. package/lib/handlers/pkg.log.js +112 -110
  18. package/lib/handlers/pkg.put.js +223 -213
  19. package/lib/handlers/versions.get.js +92 -101
  20. package/lib/main.js +47 -47
  21. package/lib/multipart/form-field.js +20 -23
  22. package/lib/multipart/form-file.js +22 -24
  23. package/lib/multipart/parser.js +231 -217
  24. package/lib/sinks/mem-entry.js +26 -31
  25. package/lib/sinks/test.js +287 -273
  26. package/lib/utils/defaults.js +11 -11
  27. package/lib/utils/globals.js +5 -5
  28. package/lib/utils/healthcheck.js +131 -108
  29. package/lib/utils/path-builders-fs.js +61 -29
  30. package/lib/utils/path-builders-uri.js +26 -18
  31. package/lib/utils/utils.js +76 -79
  32. package/package.json +20 -15
  33. package/types/classes/alias.d.ts +28 -0
  34. package/types/classes/asset.d.ts +48 -0
  35. package/types/classes/author.d.ts +17 -0
  36. package/types/classes/http-incoming.d.ts +37 -0
  37. package/types/classes/http-outgoing.d.ts +20 -0
  38. package/types/classes/meta.d.ts +17 -0
  39. package/types/classes/package.d.ts +40 -0
  40. package/types/classes/versions.d.ts +28 -0
  41. package/types/handlers/alias.delete.d.ts +33 -0
  42. package/types/handlers/alias.get.d.ts +48 -0
  43. package/types/handlers/alias.post.d.ts +83 -0
  44. package/types/handlers/alias.put.d.ts +83 -0
  45. package/types/handlers/auth.post.d.ts +82 -0
  46. package/types/handlers/map.get.d.ts +51 -0
  47. package/types/handlers/map.put.d.ts +78 -0
  48. package/types/handlers/pkg.get.d.ts +51 -0
  49. package/types/handlers/pkg.log.d.ts +51 -0
  50. package/types/handlers/pkg.put.d.ts +107 -0
  51. package/types/handlers/versions.get.d.ts +48 -0
  52. package/types/main.d.ts +44 -0
  53. package/types/multipart/form-field.d.ts +17 -0
  54. package/types/multipart/form-file.d.ts +17 -0
  55. package/types/multipart/parser.d.ts +52 -0
  56. package/types/sinks/mem-entry.d.ts +15 -0
  57. package/types/sinks/test.d.ts +32 -0
  58. package/types/utils/defaults.d.ts +9 -0
  59. package/types/utils/globals.d.ts +8 -0
  60. package/types/utils/healthcheck.d.ts +24 -0
  61. package/types/utils/path-builders-fs.d.ts +41 -0
  62. package/types/utils/path-builders-uri.d.ts +26 -0
  63. package/types/utils/utils.d.ts +6 -0
@@ -1,219 +1,229 @@
1
- import { validators } from '@eik/common';
2
- import originalUrl from 'original-url';
3
- import HttpError from 'http-errors';
4
- import Metrics from '@metrics/client';
5
- import abslog from 'abslog';
1
+ import { validators } from "@eik/common";
2
+ import originalUrl from "original-url";
3
+ import HttpError from "http-errors";
4
+ import Metrics from "@metrics/client";
5
+ import abslog from "abslog";
6
6
 
7
7
  import {
8
- createFilePathToPackage,
9
- createFilePathToVersion,
10
- createFilePathToEikJson
11
- } from '../utils/path-builders-fs.js';
12
- import { decodeUriComponent, writeJSON, readJSON, readEikJson } from '../utils/utils.js';
13
- import { createURIPathToPkgLog } from '../utils/path-builders-uri.js';
14
- import MultipartParser from '../multipart/parser.js';
15
- import HttpIncoming from '../classes/http-incoming.js';
16
- import HttpOutgoing from '../classes/http-outgoing.js';
17
- import Versions from '../classes/versions.js';
18
- import Package from '../classes/package.js';
19
- import Author from '../classes/author.js';
20
- import config from '../utils/defaults.js';
8
+ createFilePathToPackage,
9
+ createFilePathToVersion,
10
+ createFilePathToEikJson,
11
+ } from "../utils/path-builders-fs.js";
12
+ import {
13
+ decodeUriComponent,
14
+ writeJSON,
15
+ readJSON,
16
+ readEikJson,
17
+ } from "../utils/utils.js";
18
+ import { createURIPathToPkgLog } from "../utils/path-builders-uri.js";
19
+ import MultipartParser from "../multipart/parser.js";
20
+ import HttpIncoming from "../classes/http-incoming.js";
21
+ import HttpOutgoing from "../classes/http-outgoing.js";
22
+ import Versions from "../classes/versions.js";
23
+ import Package from "../classes/package.js";
24
+ import Author from "../classes/author.js";
25
+ import config from "../utils/defaults.js";
26
+
27
+ /**
28
+ * @typedef {object} PkgPutOptions
29
+ * @property {number} [pkgMaxFileSize=10000000]
30
+ * @property {string} [cacheControl]
31
+ * @property {Array<[string, string]>} [organizations] List of key-value pairs [hostname, organization]
32
+ * @property {import("@eik/sink").default} [sink]
33
+ * @property {import("abslog").AbstractLoggerOptions} [logger]
34
+ */
21
35
 
22
36
  const PkgPut = class PkgPut {
23
- constructor({
24
- pkgMaxFileSize,
25
- organizations,
26
- cacheControl,
27
- logger,
28
- sink,
29
- } = {}) {
30
- this._pkgMaxFileSize = pkgMaxFileSize || config.pkgMaxFileSize;
31
- this._organizations = organizations || config.organizations;
32
- this._cacheControl = cacheControl;
33
- this._sink = sink;
34
- this._log = abslog(logger);
35
- this._metrics = new Metrics();
36
- this._histogram = this._metrics.histogram({
37
- name: 'eik_core_pkg_put_handler',
38
- description:
39
- 'Histogram measuring time taken in @eik/core PkgPut handler method',
40
- labels: {
41
- success: true,
42
- type: 'unknown',
43
- },
44
- buckets: [
45
- 0.005,
46
- 0.01,
47
- 0.06,
48
- 0.1,
49
- 0.6,
50
- 1.0,
51
- 2.0,
52
- 4.0,
53
- ],
54
- });
55
- this._orgRegistry = new Map(this._organizations);
56
-
57
- this._multipart = new MultipartParser({
58
- pkgMaxFileSize: this._pkgMaxFileSize,
59
- legalFiles: ['package'],
60
- sink: this._sink,
61
- });
62
- }
63
-
64
- get metrics() {
65
- return this._metrics;
66
- }
67
-
68
- async _parser(incoming) {
69
- return new Promise((resolve, reject) => {
70
- this._multipart.parse(incoming).then((result) => {
71
- const pkg = new Package(incoming);
72
- result.forEach(obj => {
73
- if (obj.constructor.name === 'FormField') {
74
- pkg.setMeta(obj);
75
- }
76
- if (obj.constructor.name === 'FormFile') {
77
- obj.value.forEach((o) => {
78
- pkg.setAsset(o);
79
- })
80
- }
81
- });
82
- return pkg;
83
- }).then(async (pkg) => {
84
- const path = createFilePathToPackage(pkg);
85
- await writeJSON(
86
- this._sink,
87
- path,
88
- pkg,
89
- 'application/json',
90
- );
91
-
92
- this._log.info(
93
- `pkg:put - Successfully wrote package meta file to sink - Pathname: ${path}`,
94
- );
95
-
96
- resolve(pkg);
97
- }).catch((error) => {
98
- reject(error);
99
- });
100
- });
101
- }
102
-
103
- async _readVersions(incoming) {
104
- const path = createFilePathToVersion(incoming);
105
- let versions;
106
- try {
107
- const obj = await readJSON(this._sink, path);
108
- versions = new Versions(obj);
109
- this._log.info(
110
- `pkg:put - Successfully read version meta file from sink - Pathname: ${path}`,
111
- );
112
- } catch (error) {
113
- // File does not exist, its probably a new package
114
- versions = new Versions(incoming);
115
- this._log.info(
116
- `pkg:put - Version meta file did not exist in sink - Create new - Pathname: ${path}`,
117
- );
118
- }
119
- return versions;
120
- }
121
-
122
- async _readVersion(incoming) {
123
- const path = createFilePathToEikJson(incoming);
124
- try {
125
- await readEikJson(this._sink, path);
126
- this._log.info(
127
- `pkg:put - Found version meta file from sink - Pathname: ${path}`,
128
- );
129
- return true;
130
- } catch (error) {
131
-
132
- // File does not exist, its probably a new package
133
- this._log.info(
134
- `pkg:put - Did not find meta file in sink - Create new - Pathname: ${path}`,
135
- );
136
- return false;
137
- }
138
- }
139
-
140
- async _writeVersions(incoming, versions) {
141
- const path = createFilePathToVersion(incoming);
142
- await writeJSON(this._sink, path, versions, 'application/json');
143
- this._log.info(
144
- `pkg:put - Successfully wrote version meta file to sink - Pathname: ${path}`,
145
- );
146
- }
147
-
148
- async handler(req, user, type, name, version) {
149
-
150
- const end = this._histogram.timer();
151
-
152
- const pVersion = decodeUriComponent(version);
153
- const pName = decodeUriComponent(name);
154
-
155
- try {
156
- validators.version(pVersion);
157
- validators.name(pName);
158
- validators.type(type);
159
- } catch (error) {
160
- this._log.info(`pkg:put - Validation failed - ${error.message}`);
161
- const e = new HttpError.BadRequest();
162
- end({ labels: { success: false, status: e.status } });
163
- throw e;
164
- }
165
-
166
- const url = originalUrl(req);
167
- const org = this._orgRegistry.get(url.hostname);
168
-
169
- if (!org) {
170
- this._log.info(`pkg:put - Hostname does not match a configured organization - ${url.hostname}`);
171
- const e = new HttpError.BadRequest();
172
- end({ labels: { success: false, status: e.status, type } });
173
- throw e;
174
- }
175
-
176
- const author = new Author(user);
177
-
178
- const incoming = new HttpIncoming(req, {
179
- version: pVersion,
180
- author,
181
- type,
182
- name: pName,
183
- org,
184
- });
185
-
186
- const versionExists = await this._readVersion(incoming);
187
-
188
- if (versionExists) {
189
- this._log.info(
190
- `pkg:put - Semver version already exists for the package - Org: ${org} - Name: ${pName} - Version: ${pVersion}`,
191
- );
192
- const e = new HttpError.Conflict();
193
- end({ labels: { success: false, status: e.status, type } });
194
- throw e;
195
- }
196
-
197
- const versions = await this._readVersions(incoming);
198
- const pkg = await this._parser(incoming);
199
- versions.setVersion(pVersion, pkg.integrity);
200
-
201
- try {
202
- await this._writeVersions(incoming, versions);
203
- } catch (error) {
204
- const e = new HttpError.BadGateway();
205
- end({ labels: { success: false, status: e.status, type } });
206
- throw e;
207
- }
208
-
209
- const outgoing = new HttpOutgoing();
210
- outgoing.cacheControl = this._cacheControl;
211
- outgoing.statusCode = 303;
212
- outgoing.location = createURIPathToPkgLog(pkg);
213
-
214
- end({ labels: { status: outgoing.statusCode, type } });
215
-
216
- return outgoing;
217
- }
37
+ /**
38
+ * @param {PkgPutOptions} options
39
+ */
40
+ constructor({
41
+ pkgMaxFileSize,
42
+ organizations,
43
+ cacheControl,
44
+ logger,
45
+ sink,
46
+ } = {}) {
47
+ this._pkgMaxFileSize = pkgMaxFileSize || config.pkgMaxFileSize;
48
+ this._organizations = organizations || config.organizations;
49
+ this._cacheControl = cacheControl;
50
+ this._sink = sink;
51
+ this._log = abslog(logger);
52
+ this._metrics = new Metrics();
53
+ this._histogram = this._metrics.histogram({
54
+ name: "eik_core_pkg_put_handler",
55
+ description:
56
+ "Histogram measuring time taken in @eik/core PkgPut handler method",
57
+ labels: {
58
+ success: true,
59
+ type: "unknown",
60
+ },
61
+ buckets: [0.005, 0.01, 0.06, 0.1, 0.6, 1.0, 2.0, 4.0],
62
+ });
63
+ this._orgRegistry = new Map(this._organizations);
64
+
65
+ this._multipart = new MultipartParser({
66
+ pkgMaxFileSize: this._pkgMaxFileSize,
67
+ legalFiles: ["package"],
68
+ sink: this._sink,
69
+ });
70
+ }
71
+
72
+ get metrics() {
73
+ return this._metrics;
74
+ }
75
+
76
+ async _parser(incoming) {
77
+ return new Promise((resolve, reject) => {
78
+ this._multipart
79
+ .parse(incoming)
80
+ .then((result) => {
81
+ const pkg = new Package(incoming);
82
+ result.forEach((obj) => {
83
+ if (obj.constructor.name === "FormField") {
84
+ pkg.setMeta(obj);
85
+ }
86
+ if (obj.constructor.name === "FormFile") {
87
+ obj.value.forEach((o) => {
88
+ pkg.setAsset(o);
89
+ });
90
+ }
91
+ });
92
+ return pkg;
93
+ })
94
+ .then(async (pkg) => {
95
+ const path = createFilePathToPackage(pkg);
96
+ await writeJSON(this._sink, path, pkg, "application/json");
97
+
98
+ this._log.info(
99
+ `pkg:put - Successfully wrote package meta file to sink - Pathname: ${path}`,
100
+ );
101
+
102
+ resolve(pkg);
103
+ })
104
+ .catch((error) => {
105
+ reject(error);
106
+ });
107
+ });
108
+ }
109
+
110
+ async _readVersions(incoming) {
111
+ const path = createFilePathToVersion(incoming);
112
+ let versions;
113
+ try {
114
+ const obj = await readJSON(this._sink, path);
115
+ versions = new Versions(obj);
116
+ this._log.info(
117
+ `pkg:put - Successfully read version meta file from sink - Pathname: ${path}`,
118
+ );
119
+ // eslint-disable-next-line no-unused-vars
120
+ } catch (error) {
121
+ // File does not exist, its probably a new package
122
+ versions = new Versions(incoming);
123
+ this._log.info(
124
+ `pkg:put - Version meta file did not exist in sink - Create new - Pathname: ${path}`,
125
+ );
126
+ }
127
+ return versions;
128
+ }
129
+
130
+ async _readVersion(incoming) {
131
+ const path = createFilePathToEikJson(incoming);
132
+ try {
133
+ await readEikJson(this._sink, path);
134
+ this._log.info(
135
+ `pkg:put - Found version meta file from sink - Pathname: ${path}`,
136
+ );
137
+ return true;
138
+ // eslint-disable-next-line no-unused-vars
139
+ } catch (error) {
140
+ // File does not exist, its probably a new package
141
+ this._log.info(
142
+ `pkg:put - Did not find meta file in sink - Create new - Pathname: ${path}`,
143
+ );
144
+ return false;
145
+ }
146
+ }
147
+
148
+ async _writeVersions(incoming, versions) {
149
+ const path = createFilePathToVersion(incoming);
150
+ await writeJSON(this._sink, path, versions, "application/json");
151
+ this._log.info(
152
+ `pkg:put - Successfully wrote version meta file to sink - Pathname: ${path}`,
153
+ );
154
+ }
155
+
156
+ async handler(req, user, type, name, version) {
157
+ const end = this._histogram.timer();
158
+
159
+ const pVersion = decodeUriComponent(version);
160
+ const pName = decodeUriComponent(name);
161
+
162
+ try {
163
+ validators.version(pVersion);
164
+ validators.name(pName);
165
+ validators.type(type);
166
+ } catch (error) {
167
+ this._log.info(`pkg:put - Validation failed - ${error.message}`);
168
+ const e = new HttpError.BadRequest();
169
+ end({ labels: { success: false, status: e.status } });
170
+ throw e;
171
+ }
172
+
173
+ const url = originalUrl(req);
174
+ const org = this._orgRegistry.get(url.hostname);
175
+
176
+ if (!org) {
177
+ this._log.info(
178
+ `pkg:put - Hostname does not match a configured organization - ${url.hostname}`,
179
+ );
180
+ const e = new HttpError.BadRequest();
181
+ end({ labels: { success: false, status: e.status, type } });
182
+ throw e;
183
+ }
184
+
185
+ const author = new Author(user);
186
+
187
+ const incoming = new HttpIncoming(req, {
188
+ version: pVersion,
189
+ author,
190
+ type,
191
+ name: pName,
192
+ org,
193
+ });
194
+
195
+ const versionExists = await this._readVersion(incoming);
196
+
197
+ if (versionExists) {
198
+ this._log.info(
199
+ `pkg:put - Semver version already exists for the package - Org: ${org} - Name: ${pName} - Version: ${pVersion}`,
200
+ );
201
+ const e = new HttpError.Conflict();
202
+ end({ labels: { success: false, status: e.status, type } });
203
+ throw e;
204
+ }
205
+
206
+ const versions = await this._readVersions(incoming);
207
+ const pkg = await this._parser(incoming);
208
+ versions.setVersion(pVersion, pkg.integrity);
209
+
210
+ try {
211
+ await this._writeVersions(incoming, versions);
212
+ // eslint-disable-next-line no-unused-vars
213
+ } catch (error) {
214
+ const e = new HttpError.BadGateway();
215
+ end({ labels: { success: false, status: e.status, type } });
216
+ throw e;
217
+ }
218
+
219
+ const outgoing = new HttpOutgoing();
220
+ outgoing.cacheControl = this._cacheControl;
221
+ outgoing.statusCode = 303;
222
+ outgoing.location = createURIPathToPkgLog(pkg);
223
+
224
+ end({ labels: { status: outgoing.statusCode, type } });
225
+
226
+ return outgoing;
227
+ }
218
228
  };
219
229
  export default PkgPut;
@@ -1,118 +1,109 @@
1
- import { validators } from '@eik/common';
2
- import originalUrl from 'original-url';
3
- import HttpError from 'http-errors';
4
- import Metrics from '@metrics/client';
5
- import abslog from 'abslog';
1
+ import { validators } from "@eik/common";
2
+ import originalUrl from "original-url";
3
+ import HttpError from "http-errors";
4
+ import Metrics from "@metrics/client";
5
+ import abslog from "abslog";
6
6
 
7
- import { createFilePathToVersion } from '../utils/path-builders-fs.js';
8
- import { decodeUriComponent } from '../utils/utils.js';
9
- import HttpOutgoing from '../classes/http-outgoing.js';
10
- import config from '../utils/defaults.js';
7
+ import { createFilePathToVersion } from "../utils/path-builders-fs.js";
8
+ import { decodeUriComponent } from "../utils/utils.js";
9
+ import HttpOutgoing from "../classes/http-outgoing.js";
10
+ import config from "../utils/defaults.js";
11
+
12
+ /**
13
+ * @typedef {object} VersionsGetOptions
14
+ * @property {string} [cacheControl="no-cache"]
15
+ * @property {boolean} [etag=true]
16
+ * @property {Array<[string, string]>} [organizations]
17
+ * @property {import("@eik/sink").default} [sink]
18
+ * @property {import("abslog").AbstractLoggerOptions} [logger]
19
+ */
11
20
 
12
21
  const VersionsGet = class VersionsGet {
13
- constructor({
14
- organizations,
15
- cacheControl,
16
- logger,
17
- sink,
18
- etag,
19
- } = {}) {
20
- this._organizations = organizations || config.organizations;
21
- this._cacheControl = cacheControl || 'no-cache';
22
- this._sink = sink;
23
- this._etag = etag || config.etag;
24
- this._log = abslog(logger);
25
- this._metrics = new Metrics();
26
- this._histogram = this._metrics.histogram({
27
- name: 'eik_core_versions_get_handler',
28
- description:
29
- 'Histogram measuring time taken in @eik/core VersionsGet handler method',
30
- labels: {
31
- success: true,
32
- type: 'unknown',
33
- },
34
- buckets: [
35
- 0.005,
36
- 0.01,
37
- 0.06,
38
- 0.1,
39
- 0.6,
40
- 1.0,
41
- 2.0,
42
- 4.0,
43
- ],
44
- });
45
- this._orgRegistry = new Map(this._organizations);
46
- }
22
+ /**
23
+ * @param {VersionsGetOptions} options
24
+ */
25
+ constructor({ organizations, cacheControl, logger, sink, etag } = {}) {
26
+ this._organizations = organizations || config.organizations;
27
+ this._cacheControl = cacheControl || "no-cache";
28
+ this._sink = sink;
29
+ this._etag = etag || config.etag;
30
+ this._log = abslog(logger);
31
+ this._metrics = new Metrics();
32
+ this._histogram = this._metrics.histogram({
33
+ name: "eik_core_versions_get_handler",
34
+ description:
35
+ "Histogram measuring time taken in @eik/core VersionsGet handler method",
36
+ labels: {
37
+ success: true,
38
+ type: "unknown",
39
+ },
40
+ buckets: [0.005, 0.01, 0.06, 0.1, 0.6, 1.0, 2.0, 4.0],
41
+ });
42
+ this._orgRegistry = new Map(this._organizations);
43
+ }
47
44
 
48
- get metrics() {
49
- return this._metrics;
50
- }
45
+ get metrics() {
46
+ return this._metrics;
47
+ }
51
48
 
52
- async handler(req, type, name) {
53
- const end = this._histogram.timer();
49
+ async handler(req, type, name) {
50
+ const end = this._histogram.timer();
54
51
 
55
- const pName = decodeUriComponent(name);
52
+ const pName = decodeUriComponent(name);
56
53
 
57
- try {
58
- validators.name(pName);
59
- validators.type(type);
60
- } catch (error) {
61
- this._log.debug(
62
- `pkg:latest - Validation failed - ${error.message}`,
63
- );
64
- const e = new HttpError.NotFound();
65
- end({ labels: { success: false, status: e.status } });
66
- throw e;
67
- }
54
+ try {
55
+ validators.name(pName);
56
+ validators.type(type);
57
+ } catch (error) {
58
+ this._log.debug(`pkg:latest - Validation failed - ${error.message}`);
59
+ const e = new HttpError.NotFound();
60
+ end({ labels: { success: false, status: e.status } });
61
+ throw e;
62
+ }
68
63
 
69
- const url = originalUrl(req);
70
- const org = this._orgRegistry.get(url.hostname);
64
+ const url = originalUrl(req);
65
+ const org = this._orgRegistry.get(url.hostname);
71
66
 
72
- if (!org) {
73
- this._log.info(`pkg:latest - Hostname does not match a configured organization - ${url.hostname}`);
74
- const e = new HttpError.BadRequest();
75
- end({ labels: { success: false, status: e.status, type } });
76
- throw e;
77
- }
78
- const path = createFilePathToVersion({ org, type, name: pName });
67
+ if (!org) {
68
+ this._log.info(
69
+ `pkg:latest - Hostname does not match a configured organization - ${url.hostname}`,
70
+ );
71
+ const e = new HttpError.BadRequest();
72
+ end({ labels: { success: false, status: e.status, type } });
73
+ throw e;
74
+ }
75
+ const path = createFilePathToVersion({ org, type, name: pName });
79
76
 
80
- try {
81
- const file = await this._sink.read(path);
82
- const outgoing = new HttpOutgoing();
83
- outgoing.cacheControl = this._cacheControl;
84
- outgoing.mimeType = 'application/json';
77
+ try {
78
+ const file = await this._sink.read(path);
79
+ const outgoing = new HttpOutgoing();
80
+ outgoing.cacheControl = this._cacheControl;
81
+ outgoing.mimeType = "application/json";
85
82
 
86
- if (this._etag) {
87
- outgoing.etag = file.etag;
88
- }
83
+ if (this._etag) {
84
+ outgoing.etag = file.etag;
85
+ }
89
86
 
90
- if (
91
- this._etag &&
92
- req.headers['if-none-match'] === file.etag
93
- ) {
94
- outgoing.statusCode = 304;
95
- file.stream.destroy();
96
- } else {
97
- outgoing.statusCode = 200;
98
- outgoing.stream = file.stream;
99
- }
87
+ if (this._etag && req.headers["if-none-match"] === file.etag) {
88
+ outgoing.statusCode = 304;
89
+ file.stream.destroy();
90
+ } else {
91
+ outgoing.statusCode = 200;
92
+ outgoing.stream = file.stream;
93
+ }
100
94
 
101
- this._log.debug(
102
- `pkg:latest - Package log found - Pathname: ${path}`,
103
- );
95
+ this._log.debug(`pkg:latest - Package log found - Pathname: ${path}`);
104
96
 
105
- end({ labels: { status: outgoing.statusCode, type } });
97
+ end({ labels: { status: outgoing.statusCode, type } });
106
98
 
107
- return outgoing;
108
- } catch (error) {
109
- this._log.debug(
110
- `pkg:latest - Package log found - Pathname: ${path}`,
111
- );
112
- const e = new HttpError.NotFound();
113
- end({ labels: { success: false, status: e.status, type } });
114
- throw e;
115
- }
116
- }
99
+ return outgoing;
100
+ // eslint-disable-next-line no-unused-vars
101
+ } catch (error) {
102
+ this._log.debug(`pkg:latest - Package log found - Pathname: ${path}`);
103
+ const e = new HttpError.NotFound();
104
+ end({ labels: { success: false, status: e.status, type } });
105
+ throw e;
106
+ }
107
+ }
117
108
  };
118
109
  export default VersionsGet;