0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00
verdaccio/website/versioned_docs/version-5.x/node-api.md
Juan Picado 3d158a195a
chore(website): plugin search ui (#3539)
* chore: plugin search ui

chore: progress

chore: format code

chore: progress

chore: @verdaccio-ui/copy-clipboard

chore: search finish

* chore: ui-components

* Update ToolList.tsx

* xss protection

* Update static-data.yml

* Update AddonCard.tsx
2022-12-25 18:48:18 +01:00

1.7 KiB

id title
node-api Node API

Verdaccio can be invoked programmatically. The Node API was introduced after version verdaccio@3.0.0.

Usage

Programmatically

const startServer = require("verdaccio").default;

let config = {
    storage: "./storage",
    auth: {
        htpasswd: {
            file: "./htpasswd"
        }
    },
    uplinks: {
        npmjs: {
            url: "https://registry.npmjs.org/",
        }
    },
    self_path: "./",
    packages: {
        "@*/*": {
            access: "$all",
            publish: "$authenticated",
            proxy: "npmjs",
        },
        "**": {
            proxy: "npmjs"
        }
    },
    log: {
            type: "stdout",
            format: "pretty",
            level: "http",
        };
};

startServer(
    config,
    6000,
    undefined,
    "1.0.0",
    "verdaccio",
    (webServer, addrs) => {
        webServer.listen(
            addrs.port || addrs.path,
            addrs.host,
            () => {
                console.log(`verdaccio running on : ${addrs.host}:${addrs.port}`);
            }
        );
    }
);

Other implementations

// js
import * as verdaccioServer from 'verdaccio-server';

verdaccioServer.start();
verdaccioServer.stop();
verdaccioServer.list();
verdaccioServer.stopAll();
verdaccioServer.show();
verdaccioServer.cli();
// windows .net2
verdaccioServer.serviceInstall();
verdaccioServer.serviceUninstall();
verdaccioServer.serviceStart();
verdaccioServer.serviceStop();
verdaccioServer.serviceRestart();