npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@amazeelabs/publisher

v2.4.29

Published

## Installation

Downloads

630

Readme

Publisher

Installation

pnpm add @amazeelabs/publisher

Create publisher.config.ts file in the root of your project:

import { defineConfig } from '@amazeelabs/publisher';

export default defineConfig({
  // ...
});

Usage

pnpm publisher --help

Authentication

Can be configured in publisher.config.ts

If several authentication methods are configured, OAuth2 will be favoured. If there is no configuration, access to all routes will be granted.

For local development environments, to override configuration and skip authentication, use

PUBLISHER_SKIP_AUTHENTICATION=true

OAuth2

Prerequisite: OAuth2 server, like Drupal.

There are 2 methods: Authorization Code and Resource Owner Password. The first one should be favoured in most cases. It will ask the user to grant access to Publisher the first time then use the Drupal user login form for authentication if needed (or just redirect if the user is already authenticated in Drupal).

The second one can be used as a minimal implementation if the challenge is to be exposed in the client / the backend is only accessible from the client and not the end user.

Authorization Code

Add environment variables corresponding to the server: OAUTH2_CLIENT_ID, OAUTH2_CLIENT_SECRET, OAUTH2_TOKEN_PATH, OAUTH2_TOKEN_HOST, OAUTH2_AUTHORIZE_PATH, OAUTH2_SESSION_SECRET, OAUTH2_ENVIRONMENT_TYPE

  • OAUTH2_SESSION_SECRET: used for encryption of tokens
  • OAUTH2_ENVIRONMENT_TYPE: development or production, the latter uses secure cookies
export default defineConfig({
  oAuth2: {
    clientId: process.env.OAUTH2_CLIENT_ID || 'publisher',
    clientSecret: process.env.OAUTH2_CLIENT_ID || 'publisher',
    scope: process.env.OAUTH2_SCOPE || 'publisher',
    tokenHost: process.env.OAUTH2_TOKEN_HOST || 'http://127.0.0.1:8888',
    tokenPath: process.env.OAUTH2_TOKEN_PATH || '/oauth/token',
    authorizePath:
      process.env.OAUTH2_AUTHORIZE_PATH ||
      '/oauth/authorize?response_type=code',
    sessionSecret: process.env.OAUTH2_SESSION_SECRET || 'banana',
    environmentType: process.env.OAUTH2_ENVIRONMENT_TYPE || 'development',
    grantType: OAuth2GrantTypes.AuthorizationCode,
  },
});

Resource Owner Password

Add environment variables corresponding to the server: OAUTH2_CLIENT_ID, OAUTH2_CLIENT_SECRET, OAUTH2_TOKEN_PATH, OAUTH2_TOKEN_HOST

export default defineConfig({
  oAuth2: {
    clientId: process.env.OAUTH2_CLIENT_ID || 'publisher',
    clientSecret: process.env.OAUTH2_CLIENT_SECRET || 'publisher',
    tokenHost: process.env.OAUTH2_TOKEN_HOST || 'http://127.0.0.1:8888',
    tokenPath: process.env.OAUTH2_TOKEN_PATH || '/oauth/token',
    grantType: OAuth2GrantTypes.ResourceOwnerPassword,
  },
});

Basic Auth

export default defineConfig({
  basicAuth: {
    username: process.env.BASIC_AUTH_USERNAME || 'publisher',
    password: process.env.BASIC_AUTH_PASSWORD || 'publisher',
  },
});

Slack notifications

To be notified in case of failure.

Mandatory environment variables

  • Slack Webhook (documentation) PUBLISHER_SLACK_WEBHOOK="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
  • Slack Channel PUBLISHER_SLACK_CHANNEL="#project-ci-channel"

Optional environment variables

  • Publisher url, without a trailing slash. Adds a link to the status page, to the notification message. PUBLISHER_URL="https://build.project.com"
  • Project and Environment (Lagoon only). Adds LAGOON_PROJECT and LAGOON_ENVIRONMENT to the notification message.