Node JS API Documentation : Working Implementation Code (#3032)

* Working node JS Code

Maybe add where do the `addrs` comes from ?
Added host and port display cause otherwise user doesn't know which default address and port are.

* Removing comments 

because I'm unsure about these / they are incorrect

Please complete it if you know how to make it work with a configFilePath as third parameter

* chore: fix website config

Co-authored-by: Juan Picado <juanpicado19@gmail.com>
This commit is contained in:
(H)eDoCode 2022-03-04 19:22:02 +01:00 committed by GitHub
parent 61bbede301
commit 76d78b0328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 8 deletions

View File

@ -97,7 +97,7 @@ jobs:
- name: Audit preview URL with Lighthouse
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@v9.3.0
uses: treosh/lighthouse-ci-action@9.3.0
with:
urls: |
${{ steps.netlify_preview.outputs.preview-url }}

View File

@ -10,14 +10,56 @@ Verdaccio can be invoked programmatically. The Node API was introduced after ver
#### Programmatically {#programmatically}
```js
import startServer from 'verdaccio';
const startServer = require("verdaccio").default;
startServer(configJsonFormat, 6000, store, '1.0.0', 'verdaccio',
(webServer, addrs, pkgName, pkgVersion) => {
webServer.listen(addr.port || addr.path, addr.host, () => {
console.log('verdaccio running');
});
});
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"
}
},
logs: [
{
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 {#other-implementations}