2020-06-24 12:28:00 +02:00
|
|
|
---
|
|
|
|
id: node-api
|
2020-09-03 21:15:29 +02:00
|
|
|
title: 'Node API'
|
2020-06-24 12:28:00 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
Verdaccio can be invoked programmatically. The node API was introduced after version `verdaccio@3.0.0`.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
<div id="codefund">''</div>
|
|
|
|
|
|
|
|
#### Programmatically
|
|
|
|
|
|
|
|
```js
|
2020-09-03 21:15:29 +02:00
|
|
|
import startServer from 'verdaccio';
|
2020-06-24 12:28:00 +02:00
|
|
|
|
2020-09-17 06:48:16 +02:00
|
|
|
startServer(
|
|
|
|
configJsonFormat,
|
|
|
|
6000,
|
|
|
|
store,
|
|
|
|
'1.0.0',
|
|
|
|
'verdaccio',
|
|
|
|
(webServer, addrs, pkgName, pkgVersion) => {
|
|
|
|
webServer.listen(addr.port || addr.path, addr.host, () => {
|
|
|
|
console.log('verdaccio running');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
2020-06-24 12:28:00 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Other implementations
|
|
|
|
|
2020-09-03 21:15:29 +02:00
|
|
|
- [verdaccio-server](https://github.com/boringame/verdaccio-server) local npm registry proxy server
|
2020-06-24 12:28:00 +02:00
|
|
|
|
|
|
|
```js
|
|
|
|
// js
|
2020-09-03 21:15:29 +02:00
|
|
|
import * as verdaccioServer from 'verdaccio-server';
|
2020-06-24 12:28:00 +02:00
|
|
|
verdaccioServer.start();
|
|
|
|
verdaccioServer.stop();
|
|
|
|
verdaccioServer.list();
|
|
|
|
verdaccioServer.stopAll();
|
|
|
|
verdaccioServer.show();
|
|
|
|
verdaccioServer.cli();
|
|
|
|
// windows .net2
|
|
|
|
verdaccioServer.serviceInstall();
|
|
|
|
verdaccioServer.serviceUninstall();
|
|
|
|
verdaccioServer.serviceStart();
|
|
|
|
verdaccioServer.serviceStop();
|
|
|
|
verdaccioServer.serviceRestart();
|
|
|
|
```
|