@eik/core 1.2.27 → 1.3.1
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.
- package/CHANGELOG.md +28 -0
- package/lib/classes/alias.js +2 -3
- package/lib/classes/asset.js +4 -5
- package/lib/classes/author.js +2 -3
- package/lib/classes/http-incoming.js +2 -3
- package/lib/classes/http-outgoing.js +2 -4
- package/lib/classes/meta.js +2 -3
- package/lib/classes/package.js +4 -6
- package/lib/classes/versions.js +2 -4
- package/lib/handlers/alias.delete.js +12 -14
- package/lib/handlers/alias.get.js +15 -17
- package/lib/handlers/alias.post.js +19 -21
- package/lib/handlers/alias.put.js +19 -21
- package/lib/handlers/auth.post.js +10 -12
- package/lib/handlers/map.get.js +12 -14
- package/lib/handlers/map.put.js +26 -28
- package/lib/handlers/pkg.get.js +15 -17
- package/lib/handlers/pkg.log.js +12 -14
- package/lib/handlers/pkg.put.js +22 -25
- package/lib/handlers/versions.get.js +11 -13
- package/lib/main.js +25 -22
- package/lib/multipart/form-field.js +1 -3
- package/lib/multipart/form-file.js +1 -3
- package/lib/multipart/parser.js +14 -16
- package/lib/sinks/fs.js +10 -12
- package/lib/sinks/mem-entry.js +3 -4
- package/lib/sinks/mem.js +7 -9
- package/lib/sinks/test.js +9 -10
- package/lib/utils/defaults.js +4 -5
- package/lib/utils/globals.js +1 -3
- package/lib/utils/healthcheck.js +8 -12
- package/lib/utils/path-builders-fs.js +17 -15
- package/lib/utils/path-builders-uri.js +14 -14
- package/lib/utils/utils.js +9 -9
- package/package.json +13 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [1.3.1](https://github.com/eik-lib/core/compare/v1.3.0...v1.3.1) (2022-01-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @eik/sink to v1.2.0 ([#298](https://github.com/eik-lib/core/issues/298)) ([d60a704](https://github.com/eik-lib/core/commit/d60a7047e2451cb4985329e728e2e42acc26bf6d))
|
|
7
|
+
|
|
8
|
+
# [1.3.0](https://github.com/eik-lib/core/compare/v1.2.29...v1.3.0) (2022-01-07)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* Convert to ESM ([#297](https://github.com/eik-lib/core/issues/297)) ([86c5cb3](https://github.com/eik-lib/core/commit/86c5cb3be753b777dafb6a79753e4dd5412cd352))
|
|
14
|
+
|
|
15
|
+
## [1.2.29](https://github.com/eik-lib/core/compare/v1.2.28...v1.2.29) (2022-01-05)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* Upgrade to major version 1.3.0 of Busboy ([#296](https://github.com/eik-lib/core/issues/296)) ([295eec0](https://github.com/eik-lib/core/commit/295eec01d9c97d421f68cd3ecfd05e083716c462))
|
|
21
|
+
|
|
22
|
+
## [1.2.28](https://github.com/eik-lib/core/compare/v1.2.27...v1.2.28) (2021-11-15)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* **deps:** update dependency http-errors to v1.8.1 ([665552b](https://github.com/eik-lib/core/commit/665552b16c27bf3dd6ba5b6214c223d4ce023f99))
|
|
28
|
+
|
|
1
29
|
## [1.2.27](https://github.com/eik-lib/core/compare/v1.2.26...v1.2.27) (2021-11-03)
|
|
2
30
|
|
|
3
31
|
|
package/lib/classes/alias.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
const Alias = class Alias {
|
|
4
2
|
constructor({ name = '', type = '', alias = '', org = '' } = {}) {
|
|
5
3
|
this._version = '';
|
|
@@ -47,4 +45,5 @@ const Alias = class Alias {
|
|
|
47
45
|
return 'Alias';
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
|
-
|
|
48
|
+
|
|
49
|
+
export default Alias;
|
package/lib/classes/asset.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const mime = require('mime/lite');
|
|
4
|
-
const path = require('path');
|
|
1
|
+
import mime from 'mime';
|
|
2
|
+
import path from 'node:path';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* Meta information about an Asset.
|
|
@@ -95,4 +93,5 @@ const Asset = class Asset {
|
|
|
95
93
|
return 'Asset';
|
|
96
94
|
}
|
|
97
95
|
}
|
|
98
|
-
|
|
96
|
+
|
|
97
|
+
export default Asset;
|
package/lib/classes/author.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* A bearer object to hold misc data through a http
|
|
5
3
|
* request / response cyclus.
|
|
@@ -70,4 +68,5 @@ const HttpIncoming = class HttpIncoming {
|
|
|
70
68
|
return 'HttpIncoming';
|
|
71
69
|
}
|
|
72
70
|
};
|
|
73
|
-
|
|
71
|
+
|
|
72
|
+
export default HttpIncoming;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { stream } = require('@eik/common');
|
|
1
|
+
import { stream } from '@eik/common';
|
|
4
2
|
|
|
5
3
|
const STATUS_CODES = [
|
|
6
4
|
100, 101, 102, 103,
|
|
@@ -88,4 +86,4 @@ const HttpOutgoing = class HttpOutgoing {
|
|
|
88
86
|
return 'HttpOutgoing';
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
|
-
|
|
89
|
+
export default HttpOutgoing;
|
package/lib/classes/meta.js
CHANGED
package/lib/classes/package.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Asset = require('./asset');
|
|
5
|
-
const Meta = require('./meta');
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import Asset from './asset.js';
|
|
3
|
+
import Meta from './meta.js';
|
|
6
4
|
|
|
7
5
|
const Package = class Package {
|
|
8
6
|
constructor({ version = '', type = '', name = '', org = '', author = {} } = {}) {
|
|
@@ -85,4 +83,4 @@ const Package = class Package {
|
|
|
85
83
|
return 'Package';
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
|
-
|
|
86
|
+
export default Package;
|
package/lib/classes/versions.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const semver = require('semver');
|
|
1
|
+
import semver from 'semver';
|
|
4
2
|
|
|
5
3
|
const Versions = class Versions {
|
|
6
4
|
constructor({ versions = [], type = '', name = '', org = '' } = {}) {
|
|
@@ -65,4 +63,4 @@ const Versions = class Versions {
|
|
|
65
63
|
return 'Versions';
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
|
-
|
|
66
|
+
export default Versions;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
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';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const abslog = require('abslog');
|
|
8
|
-
|
|
9
|
-
const { createFilePathToAlias } = require('../utils/path-builders-fs');
|
|
10
|
-
const HttpOutgoing = require('../classes/http-outgoing');
|
|
11
|
-
const config = require('../utils/defaults');
|
|
12
|
-
const utils = require('../utils/utils');
|
|
7
|
+
import { createFilePathToAlias } 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';
|
|
13
11
|
|
|
14
12
|
const AliasDel = class AliasDel {
|
|
15
13
|
constructor({
|
|
@@ -61,8 +59,8 @@ const AliasDel = class AliasDel {
|
|
|
61
59
|
async handler(req, user, type, name, alias) {
|
|
62
60
|
const end = this._histogram.timer();
|
|
63
61
|
|
|
64
|
-
const pAlias =
|
|
65
|
-
const pName =
|
|
62
|
+
const pAlias = decodeUriComponent(alias);
|
|
63
|
+
const pName = decodeUriComponent(name);
|
|
66
64
|
|
|
67
65
|
try {
|
|
68
66
|
validators.alias(pAlias);
|
|
@@ -124,4 +122,4 @@ const AliasDel = class AliasDel {
|
|
|
124
122
|
return outgoing;
|
|
125
123
|
}
|
|
126
124
|
};
|
|
127
|
-
|
|
125
|
+
export default AliasDel;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import abslog from 'abslog';
|
|
5
|
+
import Metrics from '@metrics/client';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const { createURIToTargetOfAlias } = require('../utils/path-builders-uri');
|
|
10
|
-
const { createFilePathToAlias } = require('../utils/path-builders-fs');
|
|
11
|
-
const HttpOutgoing = require('../classes/http-outgoing');
|
|
12
|
-
const utils = require('../utils/utils');
|
|
13
|
-
const config = require('../utils/defaults');
|
|
7
|
+
import { decodeUriComponent, readJSON } from '../utils/utils.js';
|
|
8
|
+
import { createURIToTargetOfAlias } from '../utils/path-builders-uri.js';
|
|
9
|
+
import { createFilePathToAlias } from '../utils/path-builders-fs.js';
|
|
10
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
11
|
+
import config from '../utils/defaults.js';
|
|
14
12
|
|
|
15
13
|
const AliasGet = class AliasGet {
|
|
16
14
|
constructor({
|
|
@@ -53,9 +51,9 @@ const AliasGet = class AliasGet {
|
|
|
53
51
|
async handler(req, type, name, alias, extra) {
|
|
54
52
|
const end = this._histogram.timer();
|
|
55
53
|
|
|
56
|
-
const pAlias =
|
|
57
|
-
const pExtra =
|
|
58
|
-
const pName =
|
|
54
|
+
const pAlias = decodeUriComponent(alias);
|
|
55
|
+
const pExtra = decodeUriComponent(extra);
|
|
56
|
+
const pName = decodeUriComponent(name);
|
|
59
57
|
|
|
60
58
|
try {
|
|
61
59
|
validators.alias(pAlias);
|
|
@@ -82,7 +80,7 @@ const AliasGet = class AliasGet {
|
|
|
82
80
|
const path = createFilePathToAlias({ org, type, name: pName, alias: pAlias });
|
|
83
81
|
|
|
84
82
|
try {
|
|
85
|
-
const obj = await
|
|
83
|
+
const obj = await readJSON(this._sink, path);
|
|
86
84
|
const location = createURIToTargetOfAlias({ extra: pExtra, ...obj });
|
|
87
85
|
|
|
88
86
|
const outgoing = new HttpOutgoing();
|
|
@@ -103,4 +101,4 @@ const AliasGet = class AliasGet {
|
|
|
103
101
|
}
|
|
104
102
|
}
|
|
105
103
|
};
|
|
106
|
-
|
|
104
|
+
export default AliasGet;
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import abslog from 'abslog';
|
|
5
|
+
import Metrics from '@metrics/client';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
const originalUrl = require('original-url');
|
|
5
|
-
const HttpError = require('http-errors');
|
|
6
|
-
const abslog = require('abslog');
|
|
7
|
-
const Metrics = require('@metrics/client');
|
|
8
|
-
|
|
9
|
-
const {
|
|
7
|
+
import {
|
|
10
8
|
createFilePathToAlias,
|
|
11
9
|
createFilePathToAliasOrigin,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
} from '../utils/path-builders-fs.js';
|
|
11
|
+
import { createURIToAlias } from '../utils/path-builders-uri.js';
|
|
12
|
+
import MultipartParser from '../multipart/parser.js';
|
|
13
|
+
import HttpIncoming from '../classes/http-incoming.js';
|
|
14
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
15
|
+
import Author from '../classes/author.js';
|
|
16
|
+
import Alias from '../classes/alias.js';
|
|
17
|
+
import config from '../utils/defaults.js';
|
|
18
|
+
import { decodeUriComponent, writeJSON } from '../utils/utils.js';
|
|
21
19
|
|
|
22
20
|
const AliasPost = class AliasPost {
|
|
23
21
|
constructor({
|
|
@@ -112,7 +110,7 @@ const AliasPost = class AliasPost {
|
|
|
112
110
|
);
|
|
113
111
|
|
|
114
112
|
try {
|
|
115
|
-
await
|
|
113
|
+
await writeJSON(
|
|
116
114
|
this._sink,
|
|
117
115
|
path,
|
|
118
116
|
alias,
|
|
@@ -152,8 +150,8 @@ const AliasPost = class AliasPost {
|
|
|
152
150
|
async handler(req, user, type, name, alias) {
|
|
153
151
|
const end = this._histogram.timer();
|
|
154
152
|
|
|
155
|
-
const pAlias =
|
|
156
|
-
const pName =
|
|
153
|
+
const pAlias = decodeUriComponent(alias);
|
|
154
|
+
const pName = decodeUriComponent(name);
|
|
157
155
|
|
|
158
156
|
try {
|
|
159
157
|
validators.alias(pAlias);
|
|
@@ -208,4 +206,4 @@ const AliasPost = class AliasPost {
|
|
|
208
206
|
return outgoing;
|
|
209
207
|
}
|
|
210
208
|
};
|
|
211
|
-
|
|
209
|
+
export default AliasPost;
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import abslog from 'abslog';
|
|
5
|
+
import Metrics from '@metrics/client';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
const originalUrl = require('original-url');
|
|
5
|
-
const HttpError = require('http-errors');
|
|
6
|
-
const abslog = require('abslog');
|
|
7
|
-
const Metrics = require('@metrics/client');
|
|
8
|
-
|
|
9
|
-
const {
|
|
7
|
+
import {
|
|
10
8
|
createFilePathToAlias,
|
|
11
9
|
createFilePathToAliasOrigin
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
} from '../utils/path-builders-fs.js';
|
|
11
|
+
import { decodeUriComponent, writeJSON } from '../utils/utils.js';
|
|
12
|
+
import { createURIToAlias } from '../utils/path-builders-uri.js';
|
|
13
|
+
import MultipartParser from '../multipart/parser.js';
|
|
14
|
+
import HttpIncoming from '../classes/http-incoming.js';
|
|
15
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
16
|
+
import Author from '../classes/author.js';
|
|
17
|
+
import Alias from '../classes/alias.js';
|
|
18
|
+
import config from '../utils/defaults.js';
|
|
21
19
|
|
|
22
20
|
const AliasPut = class AliasPut {
|
|
23
21
|
constructor({
|
|
@@ -112,7 +110,7 @@ const AliasPut = class AliasPut {
|
|
|
112
110
|
);
|
|
113
111
|
|
|
114
112
|
try {
|
|
115
|
-
await
|
|
113
|
+
await writeJSON(
|
|
116
114
|
this._sink,
|
|
117
115
|
path,
|
|
118
116
|
alias,
|
|
@@ -151,8 +149,8 @@ const AliasPut = class AliasPut {
|
|
|
151
149
|
async handler(req, user, type, name, alias) {
|
|
152
150
|
const end = this._histogram.timer();
|
|
153
151
|
|
|
154
|
-
const pAlias =
|
|
155
|
-
const pName =
|
|
152
|
+
const pAlias = decodeUriComponent(alias);
|
|
153
|
+
const pName = decodeUriComponent(name);
|
|
156
154
|
|
|
157
155
|
try {
|
|
158
156
|
validators.alias(pAlias);
|
|
@@ -207,4 +205,4 @@ const AliasPut = class AliasPut {
|
|
|
207
205
|
return outgoing;
|
|
208
206
|
}
|
|
209
207
|
};
|
|
210
|
-
|
|
208
|
+
export default AliasPut;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import originalUrl from 'original-url';
|
|
2
|
+
import HttpError from 'http-errors';
|
|
3
|
+
import Metrics from '@metrics/client';
|
|
4
|
+
import abslog from 'abslog';
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const MultipartParser = require('../multipart/parser');
|
|
9
|
-
const HttpIncoming = require('../classes/http-incoming');
|
|
10
|
-
const HttpOutgoing = require('../classes/http-outgoing');
|
|
11
|
-
const Author = require('../classes/author');
|
|
12
|
-
const config = require('../utils/defaults');
|
|
6
|
+
import MultipartParser from '../multipart/parser.js';
|
|
7
|
+
import HttpIncoming from '../classes/http-incoming.js';
|
|
8
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
9
|
+
import Author from '../classes/author.js';
|
|
10
|
+
import config from '../utils/defaults.js';
|
|
13
11
|
|
|
14
12
|
const AuthPost = class AuthPost {
|
|
15
13
|
constructor({
|
|
@@ -108,4 +106,4 @@ const AuthPost = class AuthPost {
|
|
|
108
106
|
return outgoing;
|
|
109
107
|
}
|
|
110
108
|
};
|
|
111
|
-
|
|
109
|
+
export default AuthPost;
|
package/lib/handlers/map.get.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import abslog from 'abslog';
|
|
5
|
+
import Metrics from '@metrics/client';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const Metrics = require('@metrics/client');
|
|
8
|
-
|
|
9
|
-
const { createFilePathToImportMap } = require('../utils/path-builders-fs');
|
|
10
|
-
const HttpOutgoing = require('../classes/http-outgoing');
|
|
11
|
-
const config = require('../utils/defaults');
|
|
12
|
-
const utils = require('../utils/utils');
|
|
7
|
+
import { createFilePathToImportMap } from '../utils/path-builders-fs.js';
|
|
8
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
9
|
+
import config from '../utils/defaults.js';
|
|
10
|
+
import { decodeUriComponent } from '../utils/utils.js';
|
|
13
11
|
|
|
14
12
|
const MapGet = class MapGet {
|
|
15
13
|
constructor({
|
|
@@ -55,8 +53,8 @@ const MapGet = class MapGet {
|
|
|
55
53
|
async handler(req, name, version) {
|
|
56
54
|
const end = this._histogram.timer();
|
|
57
55
|
|
|
58
|
-
const pVersion =
|
|
59
|
-
const pName =
|
|
56
|
+
const pVersion = decodeUriComponent(version);
|
|
57
|
+
const pName = decodeUriComponent(name);
|
|
60
58
|
|
|
61
59
|
try {
|
|
62
60
|
validators.version(pVersion);
|
|
@@ -116,4 +114,4 @@ const MapGet = class MapGet {
|
|
|
116
114
|
}
|
|
117
115
|
}
|
|
118
116
|
};
|
|
119
|
-
|
|
117
|
+
export default MapGet;
|
package/lib/handlers/map.put.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const {
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import Busboy from 'busboy';
|
|
5
|
+
import crypto from 'node:crypto';
|
|
6
|
+
import abslog from 'abslog';
|
|
7
|
+
import Metrics from '@metrics/client';
|
|
8
|
+
|
|
9
|
+
import {
|
|
12
10
|
createFilePathToImportMap,
|
|
13
11
|
createFilePathToVersion,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
} from '../utils/path-builders-fs.js';
|
|
13
|
+
import { createURIPathToImportMap } from '../utils/path-builders-uri.js';
|
|
14
|
+
import HttpIncoming from '../classes/http-incoming.js';
|
|
15
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
16
|
+
import Versions from '../classes/versions.js';
|
|
17
|
+
import Author from '../classes/author.js';
|
|
18
|
+
import config from '../utils/defaults.js';
|
|
19
|
+
import { decodeUriComponent, streamCollector, writeJSON, readJSON, } from '../utils/utils.js';
|
|
22
20
|
|
|
23
21
|
const MapPut = class MapPut {
|
|
24
22
|
constructor({
|
|
@@ -66,7 +64,7 @@ const MapPut = class MapPut {
|
|
|
66
64
|
const path = createFilePathToImportMap(incoming);
|
|
67
65
|
const queue = [];
|
|
68
66
|
|
|
69
|
-
const busboy =
|
|
67
|
+
const busboy = Busboy({
|
|
70
68
|
headers: incoming.headers,
|
|
71
69
|
limits: {
|
|
72
70
|
fields: 0,
|
|
@@ -83,7 +81,7 @@ const MapPut = class MapPut {
|
|
|
83
81
|
}));
|
|
84
82
|
});
|
|
85
83
|
|
|
86
|
-
busboy.on('
|
|
84
|
+
busboy.on('close', () => {
|
|
87
85
|
Promise.all(queue).then((items) => {
|
|
88
86
|
// Resolve with only the first item in the array since
|
|
89
87
|
// only one uploaded file is accepted
|
|
@@ -118,7 +116,7 @@ const MapPut = class MapPut {
|
|
|
118
116
|
// parse it as JSON or not.
|
|
119
117
|
let obj = {};
|
|
120
118
|
try {
|
|
121
|
-
const str = await
|
|
119
|
+
const str = await streamCollector(file);
|
|
122
120
|
hasher.update(str);
|
|
123
121
|
obj = JSON.parse(str);
|
|
124
122
|
} catch (error) {
|
|
@@ -130,7 +128,7 @@ const MapPut = class MapPut {
|
|
|
130
128
|
// Write file to storage.
|
|
131
129
|
try {
|
|
132
130
|
this._log.info(`map:put - Start writing import map to sink - Pathname: ${path}`);
|
|
133
|
-
await
|
|
131
|
+
await writeJSON(this._sink, path, obj, 'application/json');
|
|
134
132
|
} catch (error) {
|
|
135
133
|
this._log.error(`map:put - Failed writing import map to sink - Pathname: ${path}`);
|
|
136
134
|
this._log.trace(error);
|
|
@@ -146,7 +144,7 @@ const MapPut = class MapPut {
|
|
|
146
144
|
const path = createFilePathToVersion(incoming);
|
|
147
145
|
let versions;
|
|
148
146
|
try {
|
|
149
|
-
const obj = await
|
|
147
|
+
const obj = await readJSON(this._sink, path);
|
|
150
148
|
versions = new Versions(obj);
|
|
151
149
|
this._log.info(
|
|
152
150
|
`map:put - Successfully read version meta file from sink - Pathname: ${path}`,
|
|
@@ -163,7 +161,7 @@ const MapPut = class MapPut {
|
|
|
163
161
|
|
|
164
162
|
async _writeVersions(incoming, versions) {
|
|
165
163
|
const path = createFilePathToVersion(incoming);
|
|
166
|
-
await
|
|
164
|
+
await writeJSON(this._sink, path, versions, 'application/json');
|
|
167
165
|
this._log.info(
|
|
168
166
|
`map:put - Successfully wrote version meta file to sink - Pathname: ${path}`,
|
|
169
167
|
);
|
|
@@ -172,8 +170,8 @@ const MapPut = class MapPut {
|
|
|
172
170
|
async handler(req, user, name, version) {
|
|
173
171
|
const end = this._histogram.timer();
|
|
174
172
|
|
|
175
|
-
const pVersion =
|
|
176
|
-
const pName =
|
|
173
|
+
const pVersion = decodeUriComponent(version);
|
|
174
|
+
const pName = decodeUriComponent(name);
|
|
177
175
|
|
|
178
176
|
try {
|
|
179
177
|
validators.version(pVersion);
|
|
@@ -237,4 +235,4 @@ const MapPut = class MapPut {
|
|
|
237
235
|
return outgoing;
|
|
238
236
|
}
|
|
239
237
|
};
|
|
240
|
-
|
|
238
|
+
export default MapPut;
|
package/lib/handlers/pkg.get.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const config = require('../utils/defaults');
|
|
13
|
-
const utils = require('../utils/utils');
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import abslog from 'abslog';
|
|
5
|
+
import Metrics from '@metrics/client';
|
|
6
|
+
|
|
7
|
+
import { createFilePathToAsset } from '../utils/path-builders-fs.js';
|
|
8
|
+
import { decodeUriComponent } from '../utils/utils.js';
|
|
9
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
10
|
+
import Asset from '../classes/asset.js';
|
|
11
|
+
import config from '../utils/defaults.js';
|
|
14
12
|
|
|
15
13
|
const PkgGet = class PkgGet {
|
|
16
14
|
constructor({
|
|
@@ -56,9 +54,9 @@ const PkgGet = class PkgGet {
|
|
|
56
54
|
async handler(req, type, name, version, extra) {
|
|
57
55
|
const end = this._histogram.timer();
|
|
58
56
|
|
|
59
|
-
const pVersion =
|
|
60
|
-
const pExtra =
|
|
61
|
-
const pName =
|
|
57
|
+
const pVersion = decodeUriComponent(version);
|
|
58
|
+
const pExtra = decodeUriComponent(extra);
|
|
59
|
+
const pName = decodeUriComponent(name);
|
|
62
60
|
|
|
63
61
|
try {
|
|
64
62
|
validators.version(pVersion);
|
|
@@ -126,4 +124,4 @@ const PkgGet = class PkgGet {
|
|
|
126
124
|
}
|
|
127
125
|
}
|
|
128
126
|
};
|
|
129
|
-
|
|
127
|
+
export default PkgGet;
|