Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
juanpicado committed May 13, 2024
1 parent 37016d5 commit d5dc593
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
15 changes: 7 additions & 8 deletions src/api/endpoint/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import express from 'express';

import { Auth } from '@verdaccio/auth';
import {
antiLoop,
encodeScopePackage,
match,
validateName,
validatePackage,
} from '@verdaccio/middleware';
import { Config } from '@verdaccio/types';

import Storage from '../../lib/storage';
Expand All @@ -16,14 +23,6 @@ import v1Search from './api/v1/search';
import token from './api/v1/token';
import whoami from './api/whoami';

const {
match,
validateName,
validatePackage,
encodeScopePackage,
antiLoop,
} = require('@verdaccio/middleware');

export default function (config: Config, auth: Auth, storage: Storage) {
/* eslint new-cap:off */
const app = express.Router();
Expand Down
7 changes: 3 additions & 4 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { Auth } from '@verdaccio/auth';
import { getUserAgent } from '@verdaccio/config';
import { pluginUtils } from '@verdaccio/core';
import { asyncLoadPlugin } from '@verdaccio/loaders';

import { log } from '@verdaccio/middleware';
import { errorReportingMiddleware, final, handleError } from '@verdaccio/middleware';
import { Config as IConfig } from '@verdaccio/types';

import AppConfig from '../lib/config';
Expand All @@ -19,7 +19,6 @@ import { ErrorCode } from '../lib/utils';
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';
import hookDebug from './debug';
import apiEndpoint from './endpoint';
import { errorReportingMiddleware, final, handleError } from '@verdaccio/middleware';
import { serveFavicon } from './middleware';
import webMiddleware from './web';

Expand All @@ -44,7 +43,7 @@ const defineAPI = async function (config: IConfig, storage: Storage): Promise<ex

// // Router setup
app.use(log(logger));
app.use(errorReportingMiddleware);
app.use(errorReportingMiddleware(logger));
if (config.user_agent) {
app.use(function (_req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
res.setHeader('X-Powered-By', getUserAgent(config.user_agent));
Expand Down Expand Up @@ -104,7 +103,7 @@ const defineAPI = async function (config: IConfig, storage: Storage): Promise<ex
app.get('/*', function (_, __, next: $NextFunctionVer) {
next(ErrorCode.getNotFound(API_ERROR.FILE_NOT_FOUND));
});
app.use(handleError);
app.use(handleError(logger));
app.use(final);

return app;
Expand Down
4 changes: 1 addition & 3 deletions src/api/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import buildDebug from 'debug';
import fs from 'fs';

import _ from 'lodash';
import path from 'path';
import validator from 'validator';

import { Config, Manifest } from '@verdaccio/types';

import { HTTP_STATUS } from '../lib/constants';
import { HTTP_STATUS } from '../lib/constants';
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';

const debug = buildDebug('verdaccio:middleware:favicon');
Expand Down Expand Up @@ -62,4 +61,3 @@ export interface MiddlewareError {
}

export type FinalBody = Manifest | MiddlewareError | string;

7 changes: 3 additions & 4 deletions test/helpers/initializeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import path from 'path';

import { Auth } from '@verdaccio/auth';
import { errorUtils } from '@verdaccio/core';
import { final, errorReportingMiddleware, handleError } from '@verdaccio/middleware';
import { errorReportingMiddleware, final, handleError } from '@verdaccio/middleware';
import { ConfigYaml } from '@verdaccio/types';
import { generateRandomHexString } from '@verdaccio/utils';


import Config from '../../src/lib/config';

const debug = buildDebug('verdaccio:tools:helpers:server');
Expand All @@ -35,7 +34,7 @@ export async function initializeServer(
// TODO: this might not be need it, used in apiEndpoints
app.use(express.json({ strict: false, limit: '10mb' }));
// @ts-ignore
app.use(errorReportingMiddleware);
app.use(errorReportingMiddleware(logger));

Check failure on line 37 in test/helpers/initializeServer.ts

View workflow job for this annotation

GitHub Actions / Node Lint

'logger' is not defined
for (let route of routesMiddleware) {
if (route.async) {
const middleware = await route.routes(config, auth, storage);
Expand All @@ -51,7 +50,7 @@ export async function initializeServer(
});

// @ts-ignore
app.use(handleError);
app.use(handleError(logger));

Check failure on line 53 in test/helpers/initializeServer.ts

View workflow job for this annotation

GitHub Actions / Node Lint

'logger' is not defined
// @ts-ignore
app.use(final);

Expand Down

0 comments on commit d5dc593

Please sign in to comment.