mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-30 22:34:10 -05:00
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:
parent
61bbede301
commit
76d78b0328
2 changed files with 50 additions and 8 deletions
2
.github/workflows/website.yml
vendored
2
.github/workflows/website.yml
vendored
|
@ -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 }}
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in a new issue