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

patorg-web-api-js

v2.5.0

Published

Docs: [http://pbgweb1.patorg.org/docs/patorg-web-api-js/](http://pbgweb1.patorg.org/docs/patorg-web-api-js/)\ Code: [https://pbggitlab1.patorg.org/dev/patorg-web-api-js](https://pbggitlab1.patorg.org/dev/patorg-web-api-js)

Downloads

9

Readme

PatOrg Web API JS

Docs: http://pbgweb1.patorg.org/docs/patorg-web-api-js/
Code: https://pbggitlab1.patorg.org/dev/patorg-web-api-js

Hilfreiche Funktionen zum Arbeiten mit der PatOrg Web API mit JavaScript.

Installation

npm i patorg-web-api-js

Migration von v1 auf v2

Im Code selbst gibt es keine signifikanten Breaking Changes. Es ändert sich aber die NPM-Registry von GitLab auf das öffentliche NPM. Damit ändert sich auch der Paketname von @bsw/patorg-web-api-js auf patorg-web-api-js.

Migrations-Guide

  1. Deinstalliere das alte Paket:
    npm uninstall @bsw/patorg-web-api-js
  2. Lösche die Zeile mit @bsw aus der .npmrc-Datei in deinem Projekt. Wenn es der einzige Eintrag war, kannst du die Datei auch löschen.
  3. Aktiviere wieder strengeres SSL:
    npm config set strict-ssl true
  4. Installiere das Paket:
    npm i patorg-web-api-js@latest
  5. Ersetze im Code alle Importe von @bsw/patorg-web-api-js auf patorg-web-api-js.

Neues Release erzeugen

Lokal

  1. Setze die neue Version in package.json.
  2. npm run release - Das erzeugt nen neuen Build, lädt neues Paket nach NPM hoch und deployt die neue Doku. Stelle sicher, dass du lokal mit einem berechtigten NPM-Account angemeldet bist und dass für publish-docs.js die richtigen Umgebungsvariablen gesetzt hast.
  3. Committe und pushe deine Änderungen durch Git.

Über GitLab CI/CD (veraltet)

Diese Methode funktioniert wahrscheinlich mit Umstellung auf öffentliche NPM-Registry nicht mehr. Benutze die obere Methode.

Erstelle einen neuen Commit und setze als Commit-Nachricht-Titel die neue Version. Z.B.:

git commit -m "1.0.1"
git push

Anschließend startet das CI/CD von GitLab. Es wird ein neues NPM-Paket veröffentlicht und die Doku-Seite wird neu deployt.

Benutzung

import { setBaseUrl, auth, fetchApi } from "patorg-web-api-js"

// 1. Basis-URL setzen. Muss einmalig ausgeführt werden.
setBaseUrl("http://pbgbuild6/api")

async function main() {
    // 2. Authentifizierung
    await auth("LGK", "PBG", "lgk")

    // 3. Akte lesen
    const record = await fetchApi("read", { params: "context=P6.AKTE&id=PPP" })
}
main()

React

React-Komponenten befinden sich im Unterordner patorg-web-api-js/dist/react.

Binde PowapiProvider in deine Root-Komponente ein und setze die baseUrl:

import { StrictMode } from "react"
import { createRoot } from "react-dom/client"
import App from "./App"

import PowapiProvider from "patorg-web-api-js/dist/react/PowapiProvider"

const root = createRoot(document.getElementById("root")!)

root.render(
    <StrictMode>
        <PowapiProvider baseUrl="http://pbgbuild6/api">
            <App />
        </PowapiProvider>
    </StrictMode>
)

Nutze den Hook usePowapi() und setze beim Anmeldevorgang den AccessToken:

import { Page, Header, HeaderTitle, Body } from "blue-react"

import { appLogo, appTitle, getPhrase } from "../shared"
import usePowapi from "patorg-web-api-js/dist/react/usePowapi"
import { auth, fetchApi } from "patorg-web-api-js"

export default function HomePage() {
    const { setToken } = usePowapi()

    const login = async () => {
        const token = await auth("LGK", "PBG", "lgk")
        setToken(token)
    }

    const readRecord = async () => {
        const record = await fetchApi("read", { params: "context=P6.AKTE&id=PPP" })
        console.log(record)
    }

    return (
        <Page>
            <Header>
                <HeaderTitle logo={appLogo} appTitle={appTitle}>
                    {getPhrase("HELLO_WORLD")}
                </HeaderTitle>
            </Header>

            <Body containerClass="container">
                <button type="button" className="btn btn-primary" onClick={login}>
                    Log in
                </button>

                <button type="button" className="btn btn-primary" onClick={readRecord}>
                    Read record
                </button>
            </Body>
        </Page>
    )
}

PowapiProvider hat die Komponente RefreshAccessToken eingebunden, die dafür sorgt, dass der AccessToken im Hintergrund rechtzeitig vor Ablauf erneuert wird. Props zu PowapiProvider