@eik/service 2.1.2 → 2.2.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 +14 -0
- package/bin/eik-server.js +3 -3
- package/lib/config.js +8 -4
- package/lib/main.js +255 -83
- package/lib/utils.js +1 -6
- package/package.json +21 -15
- package/types/config.d.ts +2 -0
- package/types/main.d.ts +517 -0
- package/types/utils.d.ts +10 -0
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## [2.2.1](https://github.com/eik-lib/service/compare/v2.2.0...v2.2.1) (2024-08-12)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* **deps:** update dependency @eik/core to v1.3.58 ([c199dc1](https://github.com/eik-lib/service/commit/c199dc1df3548b4573a8faf4beee775838392153))
|
7
|
+
|
8
|
+
# [2.2.0](https://github.com/eik-lib/service/compare/v2.1.2...v2.2.0) (2024-08-08)
|
9
|
+
|
10
|
+
|
11
|
+
### Features
|
12
|
+
|
13
|
+
* add constructor options to configure max sizes ([#586](https://github.com/eik-lib/service/issues/586)) ([37a60a0](https://github.com/eik-lib/service/commit/37a60a07cabde49b8e6ac45a12386e37b5a9ea91))
|
14
|
+
|
1
15
|
## [2.1.2](https://github.com/eik-lib/service/compare/v2.1.1...v2.1.2) (2024-08-05)
|
2
16
|
|
3
17
|
|
package/bin/eik-server.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
|
3
|
-
import Fastify from 'fastify'
|
2
|
+
/* eslint-disable no-unused-vars */
|
3
|
+
import Fastify from 'fastify';
|
4
4
|
import Eik from '../lib/main.js';
|
5
5
|
|
6
6
|
const eik = new Eik();
|
@@ -22,5 +22,5 @@ try {
|
|
22
22
|
|
23
23
|
await app.listen({
|
24
24
|
port: eik.config.get('http.port'),
|
25
|
-
host: eik.config.get('http.address')
|
25
|
+
host: eik.config.get('http.address'),
|
26
26
|
});
|
package/lib/config.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
1
2
|
import convict from 'convict';
|
2
3
|
import yaml from 'js-yaml';
|
3
4
|
import pino from 'pino';
|
@@ -9,7 +10,7 @@ const CWD = process.cwd();
|
|
9
10
|
|
10
11
|
let pack = {};
|
11
12
|
try {
|
12
|
-
pack = JSON.parse(fs.readFileSync(join(CWD, 'package.json')));
|
13
|
+
pack = JSON.parse(fs.readFileSync(join(CWD, 'package.json'), 'utf-8'));
|
13
14
|
} catch (error) {
|
14
15
|
/* empty */
|
15
16
|
}
|
@@ -29,11 +30,13 @@ convict.addFormat({
|
|
29
30
|
const file = fs.readFileSync(value);
|
30
31
|
return file.toString();
|
31
32
|
} catch (error) {
|
32
|
-
throw new Error(
|
33
|
+
throw new Error(
|
34
|
+
`Config could not load secret from path: ${value}`,
|
35
|
+
);
|
33
36
|
}
|
34
37
|
}
|
35
38
|
return value;
|
36
|
-
}
|
39
|
+
},
|
37
40
|
});
|
38
41
|
|
39
42
|
const conf = convict({
|
@@ -148,11 +151,12 @@ const conf = convict({
|
|
148
151
|
default: path.join(os.tmpdir(), '/eik'),
|
149
152
|
env: 'SINK_PATH',
|
150
153
|
},
|
151
|
-
}
|
154
|
+
},
|
152
155
|
});
|
153
156
|
|
154
157
|
const env = conf.get('env');
|
155
158
|
|
159
|
+
// @ts-expect-error This is in fact callable
|
156
160
|
const logger = pino({
|
157
161
|
level: conf.get('log.level'),
|
158
162
|
name: conf.get('name'),
|
package/lib/main.js
CHANGED
@@ -8,7 +8,6 @@ import eik from '@eik/core';
|
|
8
8
|
import SinkMemory from '@eik/sink-memory';
|
9
9
|
import SinkFileSystem from '@eik/sink-file-system';
|
10
10
|
|
11
|
-
|
12
11
|
import config from './config.js';
|
13
12
|
import * as utils from './utils.js';
|
14
13
|
|
@@ -19,6 +18,8 @@ import * as utils from './utils.js';
|
|
19
18
|
* @property {import('@eik/sink').default} [customSink] [Deprecated] Use sink instead
|
20
19
|
* @property {string} [aliasCacheControl]
|
21
20
|
* @property {string} [notFoundCacheControl="public, max-age=5"]
|
21
|
+
* @property {number} [pkgMaxFileSize=10000000] The limit in bytes before PUT /pkg/ starts returning 413 Content Too Large
|
22
|
+
* @property {number} [mapMaxFileSize=1000000] The limit in bytes before PUT /map/ starts returning 413 Content Too Large
|
22
23
|
*/
|
23
24
|
|
24
25
|
const EikService = class EikService {
|
@@ -31,10 +32,14 @@ const EikService = class EikService {
|
|
31
32
|
customSink,
|
32
33
|
notFoundCacheControl,
|
33
34
|
aliasCacheControl,
|
35
|
+
pkgMaxFileSize,
|
36
|
+
mapMaxFileSize,
|
34
37
|
} = options;
|
35
|
-
this._notFoundCacheControl =
|
38
|
+
this._notFoundCacheControl =
|
39
|
+
notFoundCacheControl || 'public, max-age=5';
|
36
40
|
|
37
41
|
if (!logger) {
|
42
|
+
// @ts-expect-error This is in fact callable
|
38
43
|
logger = pino({
|
39
44
|
// @ts-ignore
|
40
45
|
level: config.get('log.level'),
|
@@ -45,30 +50,67 @@ const EikService = class EikService {
|
|
45
50
|
if (sink) {
|
46
51
|
logger.info(`Using the provided sink ${sink.constructor.name}`);
|
47
52
|
} else if (customSink) {
|
48
|
-
logger.warn(
|
53
|
+
logger.warn(
|
54
|
+
'The `customSink` option is deprecated and will be removed at a later stage. Use `sink` to remove this warning.',
|
55
|
+
);
|
49
56
|
sink = customSink;
|
50
57
|
} else if (config.get('sink.type') === 'mem') {
|
51
|
-
logger.info(
|
58
|
+
logger.info(
|
59
|
+
`Server is running with a in memory sink. Uploaded files will be lost on restart!`,
|
60
|
+
);
|
52
61
|
sink = new SinkMemory();
|
53
62
|
} else {
|
54
|
-
logger.info(
|
55
|
-
|
63
|
+
logger.info(
|
64
|
+
`Server is running with the file system sink. Uploaded files will be stored under "${config.get('sink.path')}"`,
|
65
|
+
);
|
66
|
+
sink = new SinkFileSystem({
|
67
|
+
sinkFsRootPath: config.get('sink.path'),
|
68
|
+
});
|
56
69
|
}
|
57
70
|
|
58
71
|
// Transform organization config
|
59
|
-
const organizations = config
|
60
|
-
|
61
|
-
|
62
|
-
|
72
|
+
const organizations = config
|
73
|
+
.get('organization.hostnames')
|
74
|
+
.map((hostname) => [hostname, config.get('organization.name')]);
|
75
|
+
|
76
|
+
this._versionsGet = new eik.http.VersionsGet({
|
77
|
+
organizations,
|
78
|
+
sink,
|
79
|
+
logger,
|
80
|
+
});
|
81
|
+
this._aliasPost = new eik.http.AliasPost({
|
82
|
+
organizations,
|
83
|
+
sink,
|
84
|
+
logger,
|
85
|
+
});
|
63
86
|
this._aliasDel = new eik.http.AliasDel({ organizations, sink, logger });
|
64
|
-
this._aliasGet = new eik.http.AliasGet({
|
87
|
+
this._aliasGet = new eik.http.AliasGet({
|
88
|
+
organizations,
|
89
|
+
sink,
|
90
|
+
logger,
|
91
|
+
cacheControl: aliasCacheControl,
|
92
|
+
});
|
65
93
|
this._aliasPut = new eik.http.AliasPut({ organizations, sink, logger });
|
66
|
-
this._authPost = new eik.http.AuthPost({
|
94
|
+
this._authPost = new eik.http.AuthPost({
|
95
|
+
organizations,
|
96
|
+
logger,
|
97
|
+
authKey: config.get('basicAuth.key'),
|
98
|
+
});
|
67
99
|
this._pkgLog = new eik.http.PkgLog({ organizations, sink, logger });
|
68
100
|
this._pkgGet = new eik.http.PkgGet({ organizations, sink, logger });
|
69
|
-
this._pkgPut = new eik.http.PkgPut({
|
101
|
+
this._pkgPut = new eik.http.PkgPut({
|
102
|
+
organizations,
|
103
|
+
sink,
|
104
|
+
logger,
|
105
|
+
pkgMaxFileSize,
|
106
|
+
});
|
70
107
|
this._mapGet = new eik.http.MapGet({ organizations, sink, logger });
|
71
|
-
this._mapPut = new eik.http.MapPut({
|
108
|
+
this._mapPut = new eik.http.MapPut({
|
109
|
+
organizations,
|
110
|
+
sink,
|
111
|
+
logger,
|
112
|
+
mapMaxFileSize,
|
113
|
+
});
|
72
114
|
|
73
115
|
const mergeStreams = (...streams) => {
|
74
116
|
const str = new PassThrough({ objectMode: true });
|
@@ -84,7 +126,7 @@ const EikService = class EikService {
|
|
84
126
|
});
|
85
127
|
|
86
128
|
for (const stm of streams) {
|
87
|
-
stm.on('error', err => {
|
129
|
+
stm.on('error', (err) => {
|
88
130
|
logger.error(err);
|
89
131
|
});
|
90
132
|
stm.pipe(str);
|
@@ -108,7 +150,7 @@ const EikService = class EikService {
|
|
108
150
|
sink.metrics,
|
109
151
|
);
|
110
152
|
|
111
|
-
metrics.on('error', err => {
|
153
|
+
metrics.on('error', (err) => {
|
112
154
|
logger.error(err);
|
113
155
|
});
|
114
156
|
|
@@ -119,18 +161,27 @@ const EikService = class EikService {
|
|
119
161
|
|
120
162
|
// Print warnings
|
121
163
|
|
122
|
-
if (
|
123
|
-
|
164
|
+
if (
|
165
|
+
config.get('basicAuth.type') === 'key' &&
|
166
|
+
config.get('basicAuth.key') === config.default('basicAuth.key')
|
167
|
+
) {
|
168
|
+
logger.warn(
|
169
|
+
'Server is running with default basic authorization key configured! For security purposes, it is highly recommended to set a custom value!',
|
170
|
+
);
|
124
171
|
}
|
125
172
|
|
126
173
|
if (config.get('jwt.secret') === config.default('jwt.secret')) {
|
127
|
-
logger.warn(
|
174
|
+
logger.warn(
|
175
|
+
'Server is running with default jwt secret configured! For security purposes, it is highly recommended to set a custom value!',
|
176
|
+
);
|
128
177
|
}
|
129
178
|
|
130
179
|
// Print info
|
131
180
|
|
132
181
|
const hosts = config.get('organization.hostnames').join(', ');
|
133
|
-
logger.info(
|
182
|
+
logger.info(
|
183
|
+
`Files for "${hosts}" will be stored in the "${config.get('organization.name')}" organization space`,
|
184
|
+
);
|
134
185
|
}
|
135
186
|
|
136
187
|
async health() {
|
@@ -144,7 +195,9 @@ const EikService = class EikService {
|
|
144
195
|
api() {
|
145
196
|
return (app, options, done) => {
|
146
197
|
if (!app.initialConfig.ignoreTrailingSlash) {
|
147
|
-
this.logger.warn(
|
198
|
+
this.logger.warn(
|
199
|
+
'Fastify is configured with "ignoreTrailingSlash" set to "false". Its adviced to set "ignoreTrailingSlash" to "true"',
|
200
|
+
);
|
148
201
|
}
|
149
202
|
|
150
203
|
app.register(cors);
|
@@ -153,24 +206,27 @@ const EikService = class EikService {
|
|
153
206
|
app.register(jwt, {
|
154
207
|
secret: config.get('jwt.secret'),
|
155
208
|
messages: {
|
156
|
-
badRequestErrorMessage:
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
209
|
+
badRequestErrorMessage:
|
210
|
+
'Autorization header is malformatted. Format is "Authorization: Bearer [token]"',
|
211
|
+
noAuthorizationInHeaderMessage:
|
212
|
+
'Autorization header is missing!',
|
213
|
+
authorizationTokenExpiredMessage:
|
214
|
+
'Authorization token expired',
|
215
|
+
authorizationTokenInvalid: 'Authorization token is invalid',
|
216
|
+
},
|
161
217
|
});
|
162
218
|
|
163
219
|
app.decorate('authenticate', async (request, reply) => {
|
164
220
|
try {
|
165
|
-
|
221
|
+
await request.jwtVerify();
|
166
222
|
} catch (error) {
|
167
|
-
|
223
|
+
reply.send(error);
|
168
224
|
}
|
169
225
|
});
|
170
226
|
|
171
227
|
const authOptions = {
|
172
|
-
preValidation: [app.authenticate]
|
173
|
-
}
|
228
|
+
preValidation: [app.authenticate],
|
229
|
+
};
|
174
230
|
|
175
231
|
// Handle multipart upload
|
176
232
|
const _multipart = Symbol('multipart');
|
@@ -188,15 +244,17 @@ const EikService = class EikService {
|
|
188
244
|
|
189
245
|
// 404 handling
|
190
246
|
app.setNotFoundHandler((request, reply) => {
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
247
|
+
reply.header('cache-control', this._notFoundCacheControl);
|
248
|
+
reply.type('text/plain');
|
249
|
+
reply.code(404);
|
250
|
+
reply.send('Not found');
|
195
251
|
});
|
196
252
|
|
197
253
|
// Error handling
|
198
254
|
app.setErrorHandler((error, request, reply) => {
|
199
|
-
this.logger.debug(
|
255
|
+
this.logger.debug(
|
256
|
+
'Error occured during request. Error is available on trace log level.',
|
257
|
+
);
|
200
258
|
this.logger.trace(error);
|
201
259
|
reply.header('cache-control', 'no-store');
|
202
260
|
if (error.statusCode) {
|
@@ -212,15 +270,12 @@ const EikService = class EikService {
|
|
212
270
|
reply.send(createError(error.statusCode || 500));
|
213
271
|
});
|
214
272
|
|
215
|
-
|
216
273
|
//
|
217
274
|
// Routes
|
218
275
|
//
|
219
276
|
|
220
277
|
const authPostRoutes = async (request, reply) => {
|
221
|
-
const outgoing = await this._authPost.handler(
|
222
|
-
request.raw,
|
223
|
-
);
|
278
|
+
const outgoing = await this._authPost.handler(request.raw);
|
224
279
|
|
225
280
|
// Workaround due to .jwt.sign() being able to only
|
226
281
|
// deal with object literals for some reason :/
|
@@ -324,7 +379,6 @@ const EikService = class EikService {
|
|
324
379
|
reply.redirect(outgoing.location);
|
325
380
|
};
|
326
381
|
|
327
|
-
|
328
382
|
const aliasGetRoute = async (request, reply) => {
|
329
383
|
const params = utils.sanitizeParameters(request.raw.url);
|
330
384
|
const outgoing = await this._aliasGet.handler(
|
@@ -385,7 +439,6 @@ const EikService = class EikService {
|
|
385
439
|
reply.send(outgoing.body);
|
386
440
|
};
|
387
441
|
|
388
|
-
|
389
442
|
//
|
390
443
|
// Authentication
|
391
444
|
//
|
@@ -394,14 +447,16 @@ const EikService = class EikService {
|
|
394
447
|
|
395
448
|
app.post(`/${eik.prop.base_auth}/login`, authPostRoutes);
|
396
449
|
|
397
|
-
|
398
450
|
//
|
399
451
|
// Packages
|
400
452
|
//
|
401
453
|
|
402
454
|
// Get public package - scoped
|
403
455
|
// curl -X GET http://localhost:4001/pkg/@cuz/fuzz/8.4.1/main/index.js
|
404
|
-
app.get(
|
456
|
+
app.get(
|
457
|
+
`/${eik.prop.base_pkg}/@:scope/:name/:version/*`,
|
458
|
+
pkgGetRoute,
|
459
|
+
);
|
405
460
|
|
406
461
|
// Get public package - non-scoped
|
407
462
|
// curl -X GET http://localhost:4001/pkg/fuzz/8.4.1/main/index.js
|
@@ -409,7 +464,10 @@ const EikService = class EikService {
|
|
409
464
|
|
410
465
|
// Get package overview - scoped
|
411
466
|
// curl -X GET http://localhost:4001/pkg/@cuz/fuzz/8.4.1/
|
412
|
-
app.get(
|
467
|
+
app.get(
|
468
|
+
`/${eik.prop.base_pkg}/@:scope/:name/:version`,
|
469
|
+
pkgLogRoute,
|
470
|
+
);
|
413
471
|
|
414
472
|
// Get package overview - non-scoped
|
415
473
|
// curl -X GET http://localhost:4001/pkg/fuzz/8.4.1/
|
@@ -425,12 +483,19 @@ const EikService = class EikService {
|
|
425
483
|
|
426
484
|
// Put package - scoped
|
427
485
|
// curl -X PUT -i -F filedata=@archive.tgz http://localhost:4001/pkg/@cuz/fuzz/8.4.1/
|
428
|
-
app.put(
|
486
|
+
app.put(
|
487
|
+
`/${eik.prop.base_pkg}/@:scope/:name/:version`,
|
488
|
+
authOptions,
|
489
|
+
pkgPutRoute,
|
490
|
+
);
|
429
491
|
|
430
492
|
// Put package - non-scoped
|
431
493
|
// curl -X PUT -i -F filedata=@archive.tgz http://localhost:4001/pkg/fuzz/8.4.1/
|
432
|
-
app.put(
|
433
|
-
|
494
|
+
app.put(
|
495
|
+
`/${eik.prop.base_pkg}/:name/:version`,
|
496
|
+
authOptions,
|
497
|
+
pkgPutRoute,
|
498
|
+
);
|
434
499
|
|
435
500
|
//
|
436
501
|
// NPM Packages
|
@@ -438,7 +503,10 @@ const EikService = class EikService {
|
|
438
503
|
|
439
504
|
// Get public NPM package - scoped
|
440
505
|
// curl -X GET http://localhost:4001/npm/@cuz/fuzz/8.4.1/main/index.js
|
441
|
-
app.get(
|
506
|
+
app.get(
|
507
|
+
`/${eik.prop.base_npm}/@:scope/:name/:version/*`,
|
508
|
+
pkgGetRoute,
|
509
|
+
);
|
442
510
|
|
443
511
|
// Get public NPM package - non-scoped
|
444
512
|
// curl -X GET http://localhost:4001/npm/fuzz/8.4.1/main/index.js
|
@@ -446,7 +514,10 @@ const EikService = class EikService {
|
|
446
514
|
|
447
515
|
// Get NPM package overview - scoped
|
448
516
|
// curl -X GET http://localhost:4001/npm/@cuz/fuzz/8.4.1/
|
449
|
-
app.get(
|
517
|
+
app.get(
|
518
|
+
`/${eik.prop.base_npm}/@:scope/:name/:version`,
|
519
|
+
pkgLogRoute,
|
520
|
+
);
|
450
521
|
|
451
522
|
// Get NPM package overview - non-scoped
|
452
523
|
// curl -X GET http://localhost:4001/npm/fuzz/8.4.1/
|
@@ -462,12 +533,19 @@ const EikService = class EikService {
|
|
462
533
|
|
463
534
|
// Put NPM package - scoped
|
464
535
|
// curl -X PUT -i -F filedata=@archive.tgz http://localhost:4001/npm/@cuz/fuzz/8.4.1/
|
465
|
-
app.put(
|
536
|
+
app.put(
|
537
|
+
`/${eik.prop.base_npm}/@:scope/:name/:version`,
|
538
|
+
authOptions,
|
539
|
+
pkgPutRoute,
|
540
|
+
);
|
466
541
|
|
467
542
|
// Put NPM package - non-scoped
|
468
543
|
// curl -X PUT -i -F filedata=@archive.tgz http://localhost:4001/npm/fuzz/8.4.1/
|
469
|
-
app.put(
|
470
|
-
|
544
|
+
app.put(
|
545
|
+
`/${eik.prop.base_npm}/:name/:version`,
|
546
|
+
authOptions,
|
547
|
+
pkgPutRoute,
|
548
|
+
);
|
471
549
|
|
472
550
|
//
|
473
551
|
// Import Maps
|
@@ -475,7 +553,10 @@ const EikService = class EikService {
|
|
475
553
|
|
476
554
|
// Get map - scoped
|
477
555
|
// curl -X GET http://localhost:4001/map/@cuz/buzz/4.2.2
|
478
|
-
app.get(
|
556
|
+
app.get(
|
557
|
+
`/${eik.prop.base_map}/@:scope/:name/:version`,
|
558
|
+
mapGetRoute,
|
559
|
+
);
|
479
560
|
|
480
561
|
// Get map - non-scoped
|
481
562
|
// curl -X GET http://localhost:4001/map/buzz/4.2.2
|
@@ -491,114 +572,205 @@ const EikService = class EikService {
|
|
491
572
|
|
492
573
|
// Put map - scoped
|
493
574
|
// curl -X PUT -i -F map=@import-map.json http://localhost:4001/map/@cuz/buzz/4.2.2
|
494
|
-
app.put(
|
575
|
+
app.put(
|
576
|
+
`/${eik.prop.base_map}/@:scope/:name/:version`,
|
577
|
+
authOptions,
|
578
|
+
mapPutRoute,
|
579
|
+
);
|
495
580
|
|
496
581
|
// Put map - non-scoped
|
497
582
|
// curl -X PUT -i -F map=@import-map.json http://localhost:4001/map/buzz/4.2.2
|
498
|
-
app.put(
|
499
|
-
|
583
|
+
app.put(
|
584
|
+
`/${eik.prop.base_map}/:name/:version`,
|
585
|
+
authOptions,
|
586
|
+
mapPutRoute,
|
587
|
+
);
|
500
588
|
|
501
589
|
//
|
502
590
|
// Alias Packages
|
503
591
|
//
|
504
592
|
|
505
593
|
// curl -X GET -L http://localhost:4001/pkg/@cuz/fuzz/v8
|
506
|
-
app.get(
|
594
|
+
app.get(
|
595
|
+
`/${eik.prop.base_pkg}/@:scope/:name/v:alias`,
|
596
|
+
aliasGetRoute,
|
597
|
+
);
|
507
598
|
|
508
599
|
// curl -X GET -L http://localhost:4001/pkg/fuzz/v8
|
509
600
|
app.get(`/${eik.prop.base_pkg}/:name/v:alias`, aliasGetRoute);
|
510
601
|
|
511
602
|
// curl -X GET -L http://localhost:4001/pkg/@cuz/fuzz/v8/main/index.js
|
512
|
-
app.get(
|
603
|
+
app.get(
|
604
|
+
`/${eik.prop.base_pkg}/@:scope/:name/v:alias/*`,
|
605
|
+
aliasGetRoute,
|
606
|
+
);
|
513
607
|
|
514
608
|
// curl -X GET -L http://localhost:4001/pkg/fuzz/v8/main/index.js
|
515
609
|
app.get(`/${eik.prop.base_pkg}/:name/v:alias/*`, aliasGetRoute);
|
516
610
|
|
517
611
|
// curl -X PUT -i -F version=8.4.1 http://localhost:4001/pkg/@cuz/fuzz/v8
|
518
|
-
app.put(
|
612
|
+
app.put(
|
613
|
+
`/${eik.prop.base_pkg}/@:scope/:name/v:alias`,
|
614
|
+
authOptions,
|
615
|
+
aliasPutRoute,
|
616
|
+
);
|
519
617
|
|
520
618
|
// curl -X PUT -i -F version=8.4.1 http://localhost:4001/pkg/fuzz/v8
|
521
|
-
app.put(
|
619
|
+
app.put(
|
620
|
+
`/${eik.prop.base_pkg}/:name/v:alias`,
|
621
|
+
authOptions,
|
622
|
+
aliasPutRoute,
|
623
|
+
);
|
522
624
|
|
523
625
|
// curl -X POST -i -F version=8.4.1 http://localhost:4001/pkg/@cuz/lit-html/v8
|
524
|
-
app.post(
|
626
|
+
app.post(
|
627
|
+
`/${eik.prop.base_pkg}/@:scope/:name/v:alias`,
|
628
|
+
authOptions,
|
629
|
+
aliasPostRoute,
|
630
|
+
);
|
525
631
|
|
526
632
|
// curl -X POST -i -F version=8.4.1 http://localhost:4001/pkg/lit-html/v8
|
527
|
-
app.post(
|
633
|
+
app.post(
|
634
|
+
`/${eik.prop.base_pkg}/:name/v:alias`,
|
635
|
+
authOptions,
|
636
|
+
aliasPostRoute,
|
637
|
+
);
|
528
638
|
|
529
639
|
// curl -X DELETE http://localhost:4001/pkg/@cuz/fuzz/v8
|
530
|
-
app.delete(
|
640
|
+
app.delete(
|
641
|
+
`/${eik.prop.base_pkg}/@:scope/:name/v:alias`,
|
642
|
+
authOptions,
|
643
|
+
aliasDelRoute,
|
644
|
+
);
|
531
645
|
|
532
646
|
// curl -X DELETE http://localhost:4001/pkg/fuzz/v8
|
533
|
-
app.delete(
|
534
|
-
|
647
|
+
app.delete(
|
648
|
+
`/${eik.prop.base_pkg}/:name/v:alias`,
|
649
|
+
authOptions,
|
650
|
+
aliasDelRoute,
|
651
|
+
);
|
535
652
|
|
536
653
|
//
|
537
654
|
// Alias NPM Packages
|
538
655
|
//
|
539
656
|
|
540
657
|
// curl -X GET -L http://localhost:4001/npm/@cuz/fuzz/v8
|
541
|
-
app.get(
|
658
|
+
app.get(
|
659
|
+
`/${eik.prop.base_npm}/@:scope/:name/v:alias`,
|
660
|
+
aliasGetRoute,
|
661
|
+
);
|
542
662
|
|
543
663
|
// curl -X GET -L http://localhost:4001/npm/fuzz/v8
|
544
664
|
app.get(`/${eik.prop.base_npm}/:name/v:alias`, aliasGetRoute);
|
545
665
|
|
546
666
|
// curl -X GET -L http://localhost:4001/npm/@cuz/fuzz/v8/main/index.js
|
547
|
-
app.get(
|
667
|
+
app.get(
|
668
|
+
`/${eik.prop.base_npm}/@:scope/:name/v:alias/*`,
|
669
|
+
aliasGetRoute,
|
670
|
+
);
|
548
671
|
|
549
672
|
// curl -X GET -L http://localhost:4001/npm/fuzz/v8/main/index.js
|
550
673
|
app.get(`/${eik.prop.base_npm}/:name/v:alias/*`, aliasGetRoute);
|
551
674
|
|
552
675
|
// curl -X PUT -i -F version=8.4.1 http://localhost:4001/npm/@cuz/fuzz/v8
|
553
|
-
app.put(
|
676
|
+
app.put(
|
677
|
+
`/${eik.prop.base_npm}/@:scope/:name/v:alias`,
|
678
|
+
authOptions,
|
679
|
+
aliasPutRoute,
|
680
|
+
);
|
554
681
|
|
555
682
|
// curl -X PUT -i -F version=8.4.1 http://localhost:4001/npm/fuzz/v8
|
556
|
-
app.put(
|
683
|
+
app.put(
|
684
|
+
`/${eik.prop.base_npm}/:name/v:alias`,
|
685
|
+
authOptions,
|
686
|
+
aliasPutRoute,
|
687
|
+
);
|
557
688
|
|
558
689
|
// curl -X POST -i -F version=8.4.1 http://localhost:4001/npm/@cuz/lit-html/v8
|
559
|
-
app.post(
|
690
|
+
app.post(
|
691
|
+
`/${eik.prop.base_npm}/@:scope/:name/v:alias`,
|
692
|
+
authOptions,
|
693
|
+
aliasPostRoute,
|
694
|
+
);
|
560
695
|
|
561
696
|
// curl -X POST -i -F version=8.4.1 http://localhost:4001/npm/lit-html/v8
|
562
|
-
app.post(
|
697
|
+
app.post(
|
698
|
+
`/${eik.prop.base_npm}/:name/v:alias`,
|
699
|
+
authOptions,
|
700
|
+
aliasPostRoute,
|
701
|
+
);
|
563
702
|
|
564
703
|
// curl -X DELETE http://localhost:4001/npm/@cuz/fuzz/v8
|
565
|
-
app.delete(
|
704
|
+
app.delete(
|
705
|
+
`/${eik.prop.base_npm}/@:scope/:name/v:alias`,
|
706
|
+
authOptions,
|
707
|
+
aliasDelRoute,
|
708
|
+
);
|
566
709
|
|
567
710
|
// curl -X DELETE http://localhost:4001/npm/fuzz/v8
|
568
|
-
app.delete(
|
569
|
-
|
711
|
+
app.delete(
|
712
|
+
`/${eik.prop.base_npm}/:name/v:alias`,
|
713
|
+
authOptions,
|
714
|
+
aliasDelRoute,
|
715
|
+
);
|
570
716
|
|
571
717
|
//
|
572
718
|
// Alias Import Maps
|
573
719
|
//
|
574
720
|
|
575
721
|
// curl -X GET -L http://localhost:4001/map/@cuz/buzz/v4
|
576
|
-
app.get(
|
722
|
+
app.get(
|
723
|
+
`/${eik.prop.base_map}/@:scope/:name/v:alias`,
|
724
|
+
aliasGetRoute,
|
725
|
+
);
|
577
726
|
|
578
727
|
// curl -X GET -L http://localhost:4001/map/buzz/v4
|
579
728
|
app.get(`/${eik.prop.base_map}/:name/v:alias`, aliasGetRoute);
|
580
729
|
|
581
730
|
// curl -X PUT -i -F version=4.2.2 http://localhost:4001/map/@cuz/buzz/v4
|
582
|
-
app.put(
|
731
|
+
app.put(
|
732
|
+
`/${eik.prop.base_map}/@:scope/:name/v:alias`,
|
733
|
+
authOptions,
|
734
|
+
aliasPutRoute,
|
735
|
+
);
|
583
736
|
|
584
737
|
// curl -X PUT -i -F version=4.2.2 http://localhost:4001/map/buzz/v4
|
585
|
-
app.put(
|
738
|
+
app.put(
|
739
|
+
`/${eik.prop.base_map}/:name/v:alias`,
|
740
|
+
authOptions,
|
741
|
+
aliasPutRoute,
|
742
|
+
);
|
586
743
|
|
587
744
|
// curl -X POST -i -F version=4.4.2 http://localhost:4001/map/@cuz/buzz/v4
|
588
|
-
app.post(
|
745
|
+
app.post(
|
746
|
+
`/${eik.prop.base_map}/@:scope/:name/v:alias`,
|
747
|
+
authOptions,
|
748
|
+
aliasPostRoute,
|
749
|
+
);
|
589
750
|
|
590
751
|
// curl -X POST -i -F version=4.4.2 http://localhost:4001/map/buzz/v4
|
591
|
-
app.post(
|
752
|
+
app.post(
|
753
|
+
`/${eik.prop.base_map}/:name/v:alias`,
|
754
|
+
authOptions,
|
755
|
+
aliasPostRoute,
|
756
|
+
);
|
592
757
|
|
593
758
|
// curl -X DELETE http://localhost:4001/map/@cuz/buzz/v4
|
594
|
-
app.delete(
|
759
|
+
app.delete(
|
760
|
+
`/${eik.prop.base_map}/@:scope/:name/v:alias`,
|
761
|
+
authOptions,
|
762
|
+
aliasDelRoute,
|
763
|
+
);
|
595
764
|
|
596
765
|
// curl -X DELETE http://localhost:4001/map/buzz/v4
|
597
|
-
app.delete(
|
598
|
-
|
766
|
+
app.delete(
|
767
|
+
`/${eik.prop.base_map}/:name/v:alias`,
|
768
|
+
authOptions,
|
769
|
+
aliasDelRoute,
|
770
|
+
);
|
599
771
|
|
600
772
|
done();
|
601
|
-
}
|
773
|
+
};
|
602
774
|
}
|
603
775
|
};
|
604
776
|
|
package/lib/utils.js
CHANGED
package/package.json
CHANGED
@@ -1,26 +1,32 @@
|
|
1
1
|
{
|
2
2
|
"name": "@eik/service",
|
3
|
-
"version": "2.1
|
3
|
+
"version": "2.2.1",
|
4
4
|
"description": "Eik REST API as a standalone HTTP service",
|
5
5
|
"type": "module",
|
6
6
|
"main": "./lib/main.js",
|
7
|
+
"types": "./types/main.d.ts",
|
7
8
|
"bin": {
|
8
9
|
"eik-server": "bin/eik-server.js",
|
9
10
|
"eik-service": "bin/eik-server.js",
|
10
11
|
"service": "bin/eik-server.js"
|
11
12
|
},
|
12
13
|
"scripts": {
|
14
|
+
"clean": "rimraf .tap node_modules types",
|
15
|
+
"lint": "eslint .",
|
16
|
+
"lint:fix": "eslint --fix .",
|
13
17
|
"start": "node ./bin/eik-server.js | pino-pretty",
|
14
18
|
"test": "cross-env LOG_LEVEL=fatal tap ./test --disable-coverage --allow-empty-coverage --serial=test",
|
15
19
|
"test:snapshots": "cross-env LOG_LEVEL=fatal tap --snapshot --disable-coverage --allow-empty-coverage --serial=test",
|
16
|
-
"
|
17
|
-
"
|
20
|
+
"types": "run-s types:module types:test",
|
21
|
+
"types:module": "tsc",
|
22
|
+
"types:test": "tsc --project tsconfig.test.json"
|
18
23
|
},
|
19
24
|
"files": [
|
20
25
|
"CHANGELOG.md",
|
21
26
|
"package.json",
|
22
27
|
"lib",
|
23
|
-
"bin"
|
28
|
+
"bin",
|
29
|
+
"types"
|
24
30
|
],
|
25
31
|
"repository": {
|
26
32
|
"type": "git",
|
@@ -33,7 +39,7 @@
|
|
33
39
|
},
|
34
40
|
"homepage": "https://github.com/eik-lib/service#readme",
|
35
41
|
"dependencies": {
|
36
|
-
"@eik/core": "1.3.
|
42
|
+
"@eik/core": "1.3.58",
|
37
43
|
"@eik/sink": "1.2.5",
|
38
44
|
"@eik/sink-file-system": "1.0.1",
|
39
45
|
"@eik/sink-memory": "1.1.1",
|
@@ -47,21 +53,21 @@
|
|
47
53
|
"pino": "8.21.0"
|
48
54
|
},
|
49
55
|
"devDependencies": {
|
50
|
-
"@
|
51
|
-
"@
|
52
|
-
"@semantic-release
|
53
|
-
"
|
54
|
-
"
|
55
|
-
"eslint
|
56
|
-
"eslint-config-prettier": "9.1.0",
|
57
|
-
"eslint-plugin-import": "2.29.1",
|
58
|
-
"eslint-plugin-prettier": "5.2.1",
|
56
|
+
"@eik/eslint-config": "1.0.2",
|
57
|
+
"@eik/prettier-config": "1.0.1",
|
58
|
+
"@eik/semantic-release-config": "1.0.0",
|
59
|
+
"@eik/typescript-config": "1.0.0",
|
60
|
+
"cross-env": "7.0.3",
|
61
|
+
"eslint": "9.8.0",
|
59
62
|
"form-data": "4.0.0",
|
60
63
|
"node-fetch": "3.3.1",
|
64
|
+
"npm-run-all": "4.1.5",
|
61
65
|
"pino-pretty": "10.3.1",
|
62
66
|
"prettier": "3.3.3",
|
63
|
-
"
|
67
|
+
"rimraf": "6.0.1",
|
68
|
+
"semantic-release": "24.0.0",
|
64
69
|
"tap": "18.8.0",
|
70
|
+
"typescript": "5.5.4",
|
65
71
|
"unique-slug": "4.0.0"
|
66
72
|
}
|
67
73
|
}
|
package/types/main.d.ts
ADDED
@@ -0,0 +1,517 @@
|
|
1
|
+
export default EikService;
|
2
|
+
export type EikServiceOptions = {
|
3
|
+
sink?: import("@eik/sink").default;
|
4
|
+
logger?: import("pino").Logger;
|
5
|
+
/**
|
6
|
+
* [Deprecated] Use sink instead
|
7
|
+
*/
|
8
|
+
customSink?: import("@eik/sink").default;
|
9
|
+
aliasCacheControl?: string;
|
10
|
+
notFoundCacheControl?: string;
|
11
|
+
/**
|
12
|
+
* The limit in bytes before PUT /pkg/ starts returning 413 Content Too Large
|
13
|
+
*/
|
14
|
+
pkgMaxFileSize?: number;
|
15
|
+
/**
|
16
|
+
* The limit in bytes before PUT /map/ starts returning 413 Content Too Large
|
17
|
+
*/
|
18
|
+
mapMaxFileSize?: number;
|
19
|
+
};
|
20
|
+
/**
|
21
|
+
* @typedef {object} EikServiceOptions
|
22
|
+
* @property {import('@eik/sink').default} [sink]
|
23
|
+
* @property {import('pino').Logger} [logger]
|
24
|
+
* @property {import('@eik/sink').default} [customSink] [Deprecated] Use sink instead
|
25
|
+
* @property {string} [aliasCacheControl]
|
26
|
+
* @property {string} [notFoundCacheControl="public, max-age=5"]
|
27
|
+
* @property {number} [pkgMaxFileSize=10000000] The limit in bytes before PUT /pkg/ starts returning 413 Content Too Large
|
28
|
+
* @property {number} [mapMaxFileSize=1000000] The limit in bytes before PUT /map/ starts returning 413 Content Too Large
|
29
|
+
*/
|
30
|
+
declare const EikService: {
|
31
|
+
new (options?: EikServiceOptions): {
|
32
|
+
_notFoundCacheControl: string;
|
33
|
+
_versionsGet: {
|
34
|
+
_organizations: [string, string][];
|
35
|
+
_cacheControl: string;
|
36
|
+
_sink: import("@eik/sink").default;
|
37
|
+
_etag: boolean;
|
38
|
+
_log: import("abslog").ValidLogger;
|
39
|
+
_metrics: import("@metrics/client");
|
40
|
+
_histogram: import("@metrics/client").MetricsHistogram;
|
41
|
+
_orgRegistry: Map<string, string>;
|
42
|
+
readonly metrics: import("@metrics/client");
|
43
|
+
handler(req: any, type: any, name: any): Promise<{
|
44
|
+
_cacheControl: string;
|
45
|
+
_statusCode: number;
|
46
|
+
_mimeType: string;
|
47
|
+
_location: string;
|
48
|
+
_stream: any;
|
49
|
+
_body: any;
|
50
|
+
_etag: string;
|
51
|
+
cacheControl: string;
|
52
|
+
statusCode: number;
|
53
|
+
location: string;
|
54
|
+
mimeType: string;
|
55
|
+
stream: any;
|
56
|
+
body: any;
|
57
|
+
etag: string;
|
58
|
+
readonly [Symbol.toStringTag]: string;
|
59
|
+
}>;
|
60
|
+
};
|
61
|
+
_aliasPost: {
|
62
|
+
_organizations: [string, string][];
|
63
|
+
_cacheControl: string;
|
64
|
+
_sink: import("@eik/sink").default;
|
65
|
+
_log: import("abslog").ValidLogger;
|
66
|
+
_metrics: import("@metrics/client");
|
67
|
+
_histogram: import("@metrics/client").MetricsHistogram;
|
68
|
+
_orgRegistry: Map<string, string>;
|
69
|
+
_multipart: {
|
70
|
+
_pkgMaxFileSize: number;
|
71
|
+
_legalFields: string[];
|
72
|
+
_legalFiles: string[];
|
73
|
+
_sink: import("@eik/sink").default;
|
74
|
+
_log: import("abslog").ValidLogger;
|
75
|
+
parse(incoming: any): Promise<any>;
|
76
|
+
_handleField({ name, value }: {
|
77
|
+
name: any;
|
78
|
+
value: any;
|
79
|
+
}): {
|
80
|
+
_value: string;
|
81
|
+
_name: string;
|
82
|
+
readonly value: string;
|
83
|
+
readonly name: string;
|
84
|
+
toJSON(): {
|
85
|
+
value: string;
|
86
|
+
name: string;
|
87
|
+
};
|
88
|
+
readonly [Symbol.toStringTag]: string;
|
89
|
+
};
|
90
|
+
_handleFile({ fieldname, file, filename, incoming }: {
|
91
|
+
fieldname: any;
|
92
|
+
file: any;
|
93
|
+
filename: any;
|
94
|
+
incoming: any;
|
95
|
+
}): Promise<any>;
|
96
|
+
_persistFile({ incoming, entry }: {
|
97
|
+
incoming: any;
|
98
|
+
entry: any;
|
99
|
+
}): Promise<any>;
|
100
|
+
readonly [Symbol.toStringTag]: string;
|
101
|
+
};
|
102
|
+
readonly metrics: import("@metrics/client");
|
103
|
+
_parser(incoming: any): Promise<any>;
|
104
|
+
_exist(incoming: any): Promise<boolean>;
|
105
|
+
handler(req: any, user: any, type: any, name: any, alias: any): Promise<{
|
106
|
+
_cacheControl: string;
|
107
|
+
_statusCode: number;
|
108
|
+
_mimeType: string;
|
109
|
+
_location: string;
|
110
|
+
_stream: any;
|
111
|
+
_body: any;
|
112
|
+
_etag: string;
|
113
|
+
cacheControl: string;
|
114
|
+
statusCode: number;
|
115
|
+
location: string;
|
116
|
+
mimeType: string;
|
117
|
+
stream: any;
|
118
|
+
body: any;
|
119
|
+
etag: string;
|
120
|
+
readonly [Symbol.toStringTag]: string;
|
121
|
+
}>;
|
122
|
+
};
|
123
|
+
_aliasDel: {
|
124
|
+
_organizations: [string, string][];
|
125
|
+
_cacheControl: string;
|
126
|
+
_sink: import("@eik/sink").default;
|
127
|
+
_log: import("abslog").ValidLogger;
|
128
|
+
_metrics: import("@metrics/client");
|
129
|
+
_histogram: import("@metrics/client").MetricsHistogram;
|
130
|
+
_orgRegistry: Map<string, string>;
|
131
|
+
readonly metrics: import("@metrics/client");
|
132
|
+
_exist(path?: string): Promise<boolean>;
|
133
|
+
handler(req: any, user: any, type: any, name: any, alias: any): Promise<any>;
|
134
|
+
};
|
135
|
+
_aliasGet: {
|
136
|
+
_organizations: [string, string][];
|
137
|
+
_cacheControl: string;
|
138
|
+
_sink: import("@eik/sink").default;
|
139
|
+
_log: import("abslog").ValidLogger;
|
140
|
+
_metrics: import("@metrics/client");
|
141
|
+
_histogram: import("@metrics/client").MetricsHistogram;
|
142
|
+
_orgRegistry: Map<string, string>;
|
143
|
+
readonly metrics: import("@metrics/client");
|
144
|
+
handler(req: any, type: any, name: any, alias: any, extra: any): Promise<{
|
145
|
+
_cacheControl: string;
|
146
|
+
_statusCode: number;
|
147
|
+
_mimeType: string;
|
148
|
+
_location: string;
|
149
|
+
_stream: any;
|
150
|
+
_body: any;
|
151
|
+
_etag: string;
|
152
|
+
cacheControl: string;
|
153
|
+
statusCode: number;
|
154
|
+
location: string;
|
155
|
+
mimeType: string;
|
156
|
+
stream: any;
|
157
|
+
body: any;
|
158
|
+
etag: string;
|
159
|
+
readonly [Symbol.toStringTag]: string;
|
160
|
+
}>;
|
161
|
+
};
|
162
|
+
_aliasPut: {
|
163
|
+
_organizations: [string, string][];
|
164
|
+
_cacheControl: string;
|
165
|
+
_sink: import("@eik/sink").default;
|
166
|
+
_log: import("abslog").ValidLogger;
|
167
|
+
_metrics: import("@metrics/client");
|
168
|
+
_histogram: import("@metrics/client").MetricsHistogram;
|
169
|
+
_orgRegistry: Map<string, string>;
|
170
|
+
_multipart: {
|
171
|
+
_pkgMaxFileSize: number;
|
172
|
+
_legalFields: string[];
|
173
|
+
_legalFiles: string[];
|
174
|
+
_sink: import("@eik/sink").default;
|
175
|
+
_log: import("abslog").ValidLogger;
|
176
|
+
parse(incoming: any): Promise<any>;
|
177
|
+
_handleField({ name, value }: {
|
178
|
+
name: any;
|
179
|
+
value: any;
|
180
|
+
}): {
|
181
|
+
_value: string;
|
182
|
+
_name: string;
|
183
|
+
readonly value: string;
|
184
|
+
readonly name: string;
|
185
|
+
toJSON(): {
|
186
|
+
value: string;
|
187
|
+
name: string;
|
188
|
+
};
|
189
|
+
readonly [Symbol.toStringTag]: string;
|
190
|
+
};
|
191
|
+
_handleFile({ fieldname, file, filename, incoming }: {
|
192
|
+
fieldname: any;
|
193
|
+
file: any;
|
194
|
+
filename: any;
|
195
|
+
incoming: any;
|
196
|
+
}): Promise<any>;
|
197
|
+
_persistFile({ incoming, entry }: {
|
198
|
+
incoming: any;
|
199
|
+
entry: any;
|
200
|
+
}): Promise<any>;
|
201
|
+
readonly [Symbol.toStringTag]: string;
|
202
|
+
};
|
203
|
+
readonly metrics: import("@metrics/client");
|
204
|
+
_parser(incoming: any): Promise<any>;
|
205
|
+
_exist(incoming: any): Promise<boolean>;
|
206
|
+
handler(req: any, user: any, type: any, name: any, alias: any): Promise<{
|
207
|
+
_cacheControl: string;
|
208
|
+
_statusCode: number;
|
209
|
+
_mimeType: string;
|
210
|
+
_location: string;
|
211
|
+
_stream: any;
|
212
|
+
_body: any;
|
213
|
+
_etag: string;
|
214
|
+
cacheControl: string;
|
215
|
+
statusCode: number;
|
216
|
+
location: string;
|
217
|
+
mimeType: string;
|
218
|
+
stream: any;
|
219
|
+
body: any;
|
220
|
+
etag: string;
|
221
|
+
readonly [Symbol.toStringTag]: string;
|
222
|
+
}>;
|
223
|
+
};
|
224
|
+
_authPost: {
|
225
|
+
_organizations: [string, string][];
|
226
|
+
_cacheControl: string;
|
227
|
+
_authKey: string;
|
228
|
+
_log: import("abslog").ValidLogger;
|
229
|
+
_metrics: import("@metrics/client");
|
230
|
+
_histogram: import("@metrics/client").MetricsHistogram;
|
231
|
+
_orgRegistry: Map<string, string>;
|
232
|
+
_multipart: {
|
233
|
+
_pkgMaxFileSize: number;
|
234
|
+
_legalFields: string[];
|
235
|
+
_legalFiles: string[];
|
236
|
+
_sink: import("@eik/sink").default;
|
237
|
+
_log: import("abslog").ValidLogger;
|
238
|
+
parse(incoming: any): Promise<any>;
|
239
|
+
_handleField({ name, value }: {
|
240
|
+
name: any;
|
241
|
+
value: any;
|
242
|
+
}): {
|
243
|
+
_value: string;
|
244
|
+
_name: string;
|
245
|
+
readonly value: string;
|
246
|
+
readonly name: string;
|
247
|
+
toJSON(): {
|
248
|
+
value: string;
|
249
|
+
name: string;
|
250
|
+
};
|
251
|
+
readonly [Symbol.toStringTag]: string;
|
252
|
+
};
|
253
|
+
_handleFile({ fieldname, file, filename, incoming }: {
|
254
|
+
fieldname: any;
|
255
|
+
file: any;
|
256
|
+
filename: any;
|
257
|
+
incoming: any;
|
258
|
+
}): Promise<any>;
|
259
|
+
_persistFile({ incoming, entry }: {
|
260
|
+
incoming: any;
|
261
|
+
entry: any;
|
262
|
+
}): Promise<any>;
|
263
|
+
readonly [Symbol.toStringTag]: string;
|
264
|
+
};
|
265
|
+
readonly metrics: import("@metrics/client");
|
266
|
+
_parser(incoming: any): Promise<any>;
|
267
|
+
handler(req: any): Promise<{
|
268
|
+
_cacheControl: string;
|
269
|
+
_statusCode: number;
|
270
|
+
_mimeType: string;
|
271
|
+
_location: string;
|
272
|
+
_stream: any;
|
273
|
+
_body: any;
|
274
|
+
_etag: string;
|
275
|
+
cacheControl: string;
|
276
|
+
statusCode: number;
|
277
|
+
location: string;
|
278
|
+
mimeType: string;
|
279
|
+
stream: any;
|
280
|
+
body: any;
|
281
|
+
etag: string;
|
282
|
+
readonly [Symbol.toStringTag]: string;
|
283
|
+
}>;
|
284
|
+
};
|
285
|
+
_pkgLog: {
|
286
|
+
_organizations: [string, string][];
|
287
|
+
_cacheControl: string;
|
288
|
+
_sink: import("@eik/sink").default;
|
289
|
+
_etag: boolean;
|
290
|
+
_log: import("abslog").ValidLogger;
|
291
|
+
_metrics: import("@metrics/client");
|
292
|
+
_histogram: import("@metrics/client").MetricsHistogram;
|
293
|
+
_orgRegistry: Map<string, string>;
|
294
|
+
readonly metrics: import("@metrics/client");
|
295
|
+
handler(req: any, type: any, name: any, version: any): Promise<{
|
296
|
+
_cacheControl: string;
|
297
|
+
_statusCode: number;
|
298
|
+
_mimeType: string;
|
299
|
+
_location: string;
|
300
|
+
_stream: any;
|
301
|
+
_body: any;
|
302
|
+
_etag: string;
|
303
|
+
cacheControl: string;
|
304
|
+
statusCode: number;
|
305
|
+
location: string;
|
306
|
+
mimeType: string;
|
307
|
+
stream: any;
|
308
|
+
body: any;
|
309
|
+
etag: string;
|
310
|
+
readonly [Symbol.toStringTag]: string;
|
311
|
+
}>;
|
312
|
+
};
|
313
|
+
_pkgGet: {
|
314
|
+
_organizations: [string, string][];
|
315
|
+
_cacheControl: string;
|
316
|
+
_sink: import("@eik/sink").default;
|
317
|
+
_etag: boolean;
|
318
|
+
_log: import("abslog").ValidLogger;
|
319
|
+
_metrics: import("@metrics/client");
|
320
|
+
_histogram: import("@metrics/client").MetricsHistogram;
|
321
|
+
_orgRegistry: Map<string, string>;
|
322
|
+
readonly metrics: import("@metrics/client");
|
323
|
+
handler(req: any, type: any, name: any, version: any, extra: any): Promise<{
|
324
|
+
_cacheControl: string;
|
325
|
+
_statusCode: number;
|
326
|
+
_mimeType: string;
|
327
|
+
_location: string;
|
328
|
+
_stream: any;
|
329
|
+
_body: any;
|
330
|
+
_etag: string;
|
331
|
+
cacheControl: string;
|
332
|
+
statusCode: number;
|
333
|
+
location: string;
|
334
|
+
mimeType: string;
|
335
|
+
stream: any;
|
336
|
+
body: any;
|
337
|
+
etag: string;
|
338
|
+
readonly [Symbol.toStringTag]: string;
|
339
|
+
}>;
|
340
|
+
};
|
341
|
+
_pkgPut: {
|
342
|
+
_pkgMaxFileSize: number;
|
343
|
+
_organizations: [string, string][];
|
344
|
+
_cacheControl: string;
|
345
|
+
_sink: import("@eik/sink").default;
|
346
|
+
_log: import("abslog").ValidLogger;
|
347
|
+
_metrics: import("@metrics/client");
|
348
|
+
_histogram: import("@metrics/client").MetricsHistogram;
|
349
|
+
_orgRegistry: Map<string, string>;
|
350
|
+
_multipart: {
|
351
|
+
_pkgMaxFileSize: number;
|
352
|
+
_legalFields: string[];
|
353
|
+
_legalFiles: string[];
|
354
|
+
_sink: import("@eik/sink").default;
|
355
|
+
_log: import("abslog").ValidLogger;
|
356
|
+
parse(incoming: any): Promise<any>;
|
357
|
+
_handleField({ name, value }: {
|
358
|
+
name: any;
|
359
|
+
value: any;
|
360
|
+
}): {
|
361
|
+
_value: string;
|
362
|
+
_name: string;
|
363
|
+
readonly value: string;
|
364
|
+
readonly name: string;
|
365
|
+
toJSON(): {
|
366
|
+
value: string;
|
367
|
+
name: string;
|
368
|
+
};
|
369
|
+
readonly [Symbol.toStringTag]: string;
|
370
|
+
};
|
371
|
+
_handleFile({ fieldname, file, filename, incoming }: {
|
372
|
+
fieldname: any;
|
373
|
+
file: any;
|
374
|
+
filename: any;
|
375
|
+
incoming: any;
|
376
|
+
}): Promise<any>;
|
377
|
+
_persistFile({ incoming, entry }: {
|
378
|
+
incoming: any;
|
379
|
+
entry: any;
|
380
|
+
}): Promise<any>;
|
381
|
+
readonly [Symbol.toStringTag]: string;
|
382
|
+
};
|
383
|
+
readonly metrics: import("@metrics/client");
|
384
|
+
_parser(incoming: any): Promise<any>;
|
385
|
+
_readVersions(incoming: any): Promise<{
|
386
|
+
_versions: Map<any, any>;
|
387
|
+
_type: string;
|
388
|
+
_name: string;
|
389
|
+
_org: string;
|
390
|
+
readonly versions: [any, any][];
|
391
|
+
readonly type: string;
|
392
|
+
readonly name: string;
|
393
|
+
readonly org: string;
|
394
|
+
setVersion(version: any, integrity: any): void;
|
395
|
+
getVersion(major: any): any;
|
396
|
+
check(version: any): boolean;
|
397
|
+
toJSON(): {
|
398
|
+
versions: [any, any][];
|
399
|
+
type: string;
|
400
|
+
name: string;
|
401
|
+
org: string;
|
402
|
+
};
|
403
|
+
readonly [Symbol.toStringTag]: string;
|
404
|
+
}>;
|
405
|
+
_readVersion(incoming: any): Promise<boolean>;
|
406
|
+
_writeVersions(incoming: any, versions: any): Promise<void>;
|
407
|
+
handler(req: any, user: any, type: any, name: any, version: any): Promise<{
|
408
|
+
_cacheControl: string;
|
409
|
+
_statusCode: number;
|
410
|
+
_mimeType: string;
|
411
|
+
_location: string;
|
412
|
+
_stream: any;
|
413
|
+
_body: any;
|
414
|
+
_etag: string;
|
415
|
+
cacheControl: string;
|
416
|
+
statusCode: number;
|
417
|
+
location: string;
|
418
|
+
mimeType: string;
|
419
|
+
stream: any;
|
420
|
+
body: any;
|
421
|
+
etag: string;
|
422
|
+
readonly [Symbol.toStringTag]: string;
|
423
|
+
}>;
|
424
|
+
};
|
425
|
+
_mapGet: {
|
426
|
+
_organizations: [string, string][];
|
427
|
+
_cacheControl: string;
|
428
|
+
_sink: import("@eik/sink").default;
|
429
|
+
_etag: boolean;
|
430
|
+
_log: import("abslog").ValidLogger;
|
431
|
+
_metrics: import("@metrics/client");
|
432
|
+
_histogram: import("@metrics/client").MetricsHistogram;
|
433
|
+
_orgRegistry: Map<string, string>;
|
434
|
+
readonly metrics: import("@metrics/client");
|
435
|
+
handler(req: any, name: any, version: any): Promise<{
|
436
|
+
_cacheControl: string;
|
437
|
+
_statusCode: number;
|
438
|
+
_mimeType: string;
|
439
|
+
_location: string;
|
440
|
+
_stream: any;
|
441
|
+
_body: any;
|
442
|
+
_etag: string;
|
443
|
+
cacheControl: string;
|
444
|
+
statusCode: number;
|
445
|
+
location: string;
|
446
|
+
mimeType: string;
|
447
|
+
stream: any;
|
448
|
+
body: any;
|
449
|
+
etag: string;
|
450
|
+
readonly [Symbol.toStringTag]: string;
|
451
|
+
}>;
|
452
|
+
};
|
453
|
+
_mapPut: {
|
454
|
+
_mapMaxFileSize: number;
|
455
|
+
_organizations: [string, string][];
|
456
|
+
_cacheControl: string;
|
457
|
+
_sink: import("@eik/sink").default;
|
458
|
+
_log: import("abslog").ValidLogger;
|
459
|
+
_metrics: import("@metrics/client");
|
460
|
+
_histogram: import("@metrics/client").MetricsHistogram;
|
461
|
+
_orgRegistry: Map<string, string>;
|
462
|
+
readonly metrics: import("@metrics/client");
|
463
|
+
_parser(incoming: any): Promise<any>;
|
464
|
+
_handleFile({ fieldname, file, path }: {
|
465
|
+
fieldname: any;
|
466
|
+
file: any;
|
467
|
+
path: any;
|
468
|
+
}): Promise<string>;
|
469
|
+
_readVersions(incoming: any): Promise<{
|
470
|
+
_versions: Map<any, any>;
|
471
|
+
_type: string;
|
472
|
+
_name: string;
|
473
|
+
_org: string;
|
474
|
+
readonly versions: [any, any][];
|
475
|
+
readonly type: string;
|
476
|
+
readonly name: string;
|
477
|
+
readonly org: string;
|
478
|
+
setVersion(version: any, integrity: any): void;
|
479
|
+
getVersion(major: any): any;
|
480
|
+
check(version: any): boolean;
|
481
|
+
toJSON(): {
|
482
|
+
versions: [any, any][];
|
483
|
+
type: string;
|
484
|
+
name: string;
|
485
|
+
org: string;
|
486
|
+
};
|
487
|
+
readonly [Symbol.toStringTag]: string;
|
488
|
+
}>;
|
489
|
+
_writeVersions(incoming: any, versions: any): Promise<void>;
|
490
|
+
handler(req: any, user: any, name: any, version: any): Promise<{
|
491
|
+
_cacheControl: string;
|
492
|
+
_statusCode: number;
|
493
|
+
_mimeType: string;
|
494
|
+
_location: string;
|
495
|
+
_stream: any;
|
496
|
+
_body: any;
|
497
|
+
_etag: string;
|
498
|
+
cacheControl: string;
|
499
|
+
statusCode: number;
|
500
|
+
location: string;
|
501
|
+
mimeType: string;
|
502
|
+
stream: any;
|
503
|
+
body: any;
|
504
|
+
etag: string;
|
505
|
+
readonly [Symbol.toStringTag]: string;
|
506
|
+
}>;
|
507
|
+
};
|
508
|
+
metrics: PassThrough;
|
509
|
+
config: any;
|
510
|
+
logger: pino.Logger<never>;
|
511
|
+
sink: import("@eik/sink").default;
|
512
|
+
health(): Promise<void>;
|
513
|
+
api(): (app: any, options: any, done: any) => void;
|
514
|
+
};
|
515
|
+
};
|
516
|
+
import { PassThrough } from 'stream';
|
517
|
+
import pino from 'pino';
|
package/types/utils.d.ts
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
export function sanitizeParameters(url?: string): {
|
2
|
+
version: string;
|
3
|
+
extras: any;
|
4
|
+
alias: string;
|
5
|
+
name: any;
|
6
|
+
type: string;
|
7
|
+
};
|
8
|
+
export function sanitizeExtras(extras: any, version: any): any;
|
9
|
+
export function sanitizeAlias(alias?: string): string;
|
10
|
+
export function sanitizeName(scope: any, name: any): any;
|