chore: replace mime package with constants (#5471)
* chore: replace mime package with constants * Revert types/mime * Revert types/mime * Update lock file
This commit is contained in:
6
.changeset/fuzzy-cups-help.md
Normal file
6
.changeset/fuzzy-cups-help.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@verdaccio/middleware': patch
|
||||
'@verdaccio/api': patch
|
||||
---
|
||||
|
||||
chore: replace mime package with constants
|
||||
@@ -50,8 +50,7 @@
|
||||
"@verdaccio/store": "workspace:8.0.0-next-8.24",
|
||||
"debug": "4.4.3",
|
||||
"express": "4.21.2",
|
||||
"lodash": "4.17.21",
|
||||
"mime": "2.6.0"
|
||||
"lodash": "4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@verdaccio/test-helper": "workspace:4.0.0-next-8.8",
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { Router } from 'express';
|
||||
import _ from 'lodash';
|
||||
import mime from 'mime';
|
||||
|
||||
import { Auth } from '@verdaccio/auth';
|
||||
import { constants, errorUtils } from '@verdaccio/core';
|
||||
import { HEADERS, constants, errorUtils } from '@verdaccio/core';
|
||||
import { allow, media } from '@verdaccio/middleware';
|
||||
import { DIST_TAGS_API_ENDPOINTS } from '@verdaccio/middleware';
|
||||
import { Storage } from '@verdaccio/store';
|
||||
@@ -42,14 +41,14 @@ export default function (route: Router, auth: Auth, storage: Storage, logger: Lo
|
||||
route.put(
|
||||
DIST_TAGS_API_ENDPOINTS.tagging,
|
||||
can('publish'),
|
||||
media(mime.getType('json')),
|
||||
media(HEADERS.JSON),
|
||||
addTagPackageVersionMiddleware
|
||||
);
|
||||
|
||||
route.put(
|
||||
DIST_TAGS_API_ENDPOINTS.tagging_package,
|
||||
can('publish'),
|
||||
media(mime.getType('json')),
|
||||
media(HEADERS.JSON),
|
||||
addTagPackageVersionMiddleware
|
||||
);
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import buildDebug from 'debug';
|
||||
import { Router } from 'express';
|
||||
import mime from 'mime';
|
||||
|
||||
import { Auth } from '@verdaccio/auth';
|
||||
import { API_MESSAGE, HTTP_STATUS } from '@verdaccio/core';
|
||||
import { API_MESSAGE, HEADERS, HTTP_STATUS } from '@verdaccio/core';
|
||||
import { allow, expectJson, media } from '@verdaccio/middleware';
|
||||
// import star from './star';
|
||||
import { PUBLISH_API_ENDPOINTS } from '@verdaccio/middleware';
|
||||
@@ -122,7 +121,7 @@ export default function publish(
|
||||
router.put(
|
||||
PUBLISH_API_ENDPOINTS.add_package,
|
||||
can('publish'),
|
||||
media(mime.getType('json')),
|
||||
media(HEADERS.JSON),
|
||||
expectJson,
|
||||
publishPackage(storage, logger, 'publish one version')
|
||||
);
|
||||
@@ -130,7 +129,7 @@ export default function publish(
|
||||
router.put(
|
||||
PUBLISH_API_ENDPOINTS.publish_package,
|
||||
can('unpublish'),
|
||||
media(mime.getType('json')),
|
||||
media(HEADERS.JSON),
|
||||
expectJson,
|
||||
publishPackage(storage, logger, 'publish with revision')
|
||||
);
|
||||
|
||||
@@ -49,8 +49,7 @@
|
||||
"express": "4.21.2",
|
||||
"express-rate-limit": "5.5.1",
|
||||
"lodash": "4.17.21",
|
||||
"lru-cache": "7.18.3",
|
||||
"mime": "2.6.0"
|
||||
"lru-cache": "7.18.3"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import mime from 'mime';
|
||||
import request from 'supertest';
|
||||
import { test } from 'vitest';
|
||||
|
||||
@@ -9,7 +8,7 @@ import { getApp } from './helper';
|
||||
|
||||
test('media is json', async () => {
|
||||
const app = getApp([]);
|
||||
app.get('/json', media(mime.getType('json')), (req, res) => {
|
||||
app.get('/json', media(HEADERS.JSON), (req, res) => {
|
||||
res.status(200).json();
|
||||
});
|
||||
|
||||
@@ -22,7 +21,7 @@ test('media is json', async () => {
|
||||
|
||||
test('media is json with charset', async () => {
|
||||
const app = getApp([]);
|
||||
app.get('/json', media(mime.getType('json')), (req, res) => {
|
||||
app.get('/json', media(HEADERS.JSON), (req, res) => {
|
||||
res.status(200).json();
|
||||
});
|
||||
|
||||
@@ -35,7 +34,7 @@ test('media is json with charset', async () => {
|
||||
|
||||
test('media is not json', async () => {
|
||||
const app = getApp([]);
|
||||
app.get('/json', media(mime.getType('json')), (req, res) => {
|
||||
app.get('/json', media(HEADERS.JSON), (req, res) => {
|
||||
res.status(HTTP_STATUS.OK).json({});
|
||||
});
|
||||
|
||||
@@ -48,7 +47,7 @@ test('media is not json', async () => {
|
||||
|
||||
test('missing content-type', async () => {
|
||||
const app = getApp([]);
|
||||
app.get('/json', media(mime.getType('json')), (req, res) => {
|
||||
app.get('/json', media(HEADERS.JSON), (req, res) => {
|
||||
res.status(HTTP_STATUS.OK).json({});
|
||||
});
|
||||
|
||||
|
||||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@@ -581,9 +581,6 @@ importers:
|
||||
lodash:
|
||||
specifier: 4.17.21
|
||||
version: 4.17.21
|
||||
mime:
|
||||
specifier: 2.6.0
|
||||
version: 2.6.0
|
||||
devDependencies:
|
||||
'@verdaccio/test-helper':
|
||||
specifier: workspace:4.0.0-next-8.8
|
||||
@@ -965,9 +962,6 @@ importers:
|
||||
lru-cache:
|
||||
specifier: 7.18.3
|
||||
version: 7.18.3
|
||||
mime:
|
||||
specifier: 2.6.0
|
||||
version: 2.6.0
|
||||
devDependencies:
|
||||
'@verdaccio/logger':
|
||||
specifier: workspace:8.0.0-next-8.24
|
||||
@@ -5723,10 +5717,10 @@ packages:
|
||||
resolution: {integrity: sha512-fnzN9xAKb3IPEoKgAkbpDE+8Q5J+QoCThPTVv3oKDHUe5xBpENP7ZwXC6HZnXBmVPLK5zfUZrphPe6zeCTPyrQ==}
|
||||
|
||||
'@types/mime@1.3.3':
|
||||
resolution: {integrity: sha512-Ys+/St+2VF4+xuY6+kDIXGxbNRO0mesVg0bbxEfB97Od1Vjpjx9KD1qxs64Gcb3CWPirk9Xe+PT4YiiHQ9T+eg==}
|
||||
resolution: {integrity: sha512-Ys+/St+2VF4+xuY6+kDIXGxbNRO0mesVg0bbxEfB97Od1Vjpjx9KD1qxs64Gcb3CWPirk9Xe+PT4YiiHQ9T+eg==, tarball: https://registry.npmjs.org/@types/mime/-/mime-1.3.3.tgz}
|
||||
|
||||
'@types/mime@3.0.4':
|
||||
resolution: {integrity: sha512-iJt33IQnVRkqeqC7PzBHPTC6fDlRNRW8vjrgqtScAhrmMwe8c4Eo7+fUGTa+XdWrpEgpyKWMYmi2dIwMAYRzPw==}
|
||||
resolution: {integrity: sha512-iJt33IQnVRkqeqC7PzBHPTC6fDlRNRW8vjrgqtScAhrmMwe8c4Eo7+fUGTa+XdWrpEgpyKWMYmi2dIwMAYRzPw==, tarball: https://registry.npmjs.org/@types/mime/-/mime-3.0.4.tgz}
|
||||
|
||||
'@types/minimatch@3.0.5':
|
||||
resolution: {integrity: sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==}
|
||||
|
||||
Reference in New Issue
Block a user