Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@verdaccio/web

Package Overview
Dependencies
Maintainers
4
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@verdaccio/web

web ui middleware

  • 6.0.0-6-next.23
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.3K
increased by32.72%
Maintainers
4
Weekly downloads
 
Created
Source

import buildDebug from 'debug'; import { Router } from 'express';

import { IAuth } from '@verdaccio/auth'; import { HEADERS, HEADER_TYPE } from '@verdaccio/core'; import { $NextFunctionVer, $RequestExtend, $ResponseExtend, allow } from '@verdaccio/middleware'; import sanitizyReadme from '@verdaccio/readme'; import { Storage } from '@verdaccio/store'; import { Package } from '@verdaccio/types';

import { AuthorAvatar, addScope, parseReadme } from '../utils/web-utils';

export { $RequestExtend, $ResponseExtend, $NextFunctionVer }; // Was required by other packages

export type PackageExt = Package & { author: AuthorAvatar; dist?: { tarball: string } };

const debug = buildDebug('verdaccio:web:api:readme');

export const NOT_README_FOUND = 'ERROR: No README data found!';

function addReadmeWebApi(storage: Storage, auth: IAuth): Router { debug('initialized readme web api'); const can = allow(auth); const pkgRouter = Router(); /* eslint new-cap: 0 */

pkgRouter.get( '/package/readme/(@:scope/)?:package/:version?', can('access'), function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void { debug('readme hit'); const packageName = req.params.scope ? addScope(req.params.scope, req.params.package) : req.params.package; debug('readme name %o', packageName);

  // @ts-ignore
  storage.getPackage({
    name: packageName,
    uplinksLook: true,
    req,
    callback: function (err, info): void {
      debug('readme plg %o', info?.name);
      if (err) {
        return next(err);
      }

      res.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_PLAIN_UTF8);
      try {
        next(parseReadme(info.name, info.readme));
      } catch {
        next(sanitizyReadme(NOT_README_FOUND));
      }
    },
  });
}

); return pkgRouter; }

export default addReadmeWebApi;

Keywords

FAQs

Package last updated on 15 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc