Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
add usage to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
TimurRin committed Feb 26, 2024
1 parent 5bfba09 commit c71e461
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,40 @@ npm install -g snapserve

To access global plugins (`snapserve-*`), use `export NODE_PATH=$(npm root -g)`. To make the `NODE_PATH` setting permanent for Node.js, you can add it to your user's profile configuration file. This file is typically `~/.bash_profile`, `~/.bashrc`, `~/.profile`, or `~/.zshrc`, depending on which shell you are using.

### Configuration

File `~/.config/cinnabar-forge/snapserve/users.json` contains login-password pairs for Basic Authorization

### Usage

Serve current directory:
```bash
snapserve
```
TODO

Serve current directory at port `42069`:
```bash
snapserve -p 42069
```

Serve directory `/home/user/nice`:
```bash
snapserve -f /home/user/nice
```

Serve current directory with disabled Basic Authorization:
```bash
snapserve --noAuth
```

Serve current directory with built-in `gallery` mode:
```bash
snapserve -m gallery
```

Serve current directory with `snapserve-wonka` npm package:
```bash
snapserve -m npm-wonka
```

## Contributing
Expand All @@ -36,6 +66,8 @@ cd snapserve
npm ci
```

You can also develop a plugin! See [snapserve-wonka](https://github.com/cinnabar-forge/snapserve-wonka) as example to start.

## License

Cinnabar Forge SnapServe is licensed under the ISC License - see the [LICENSE](LICENSE) file for details.
Expand Down
5 changes: 2 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ program
.option("-n, --noAuth", "Disable auth")
.option(
"-m, --mode <MODE>",
"Specify the mode (default, gallery)",
"Specify the mode (default, gallery, npm-wonka)",
"default",
);

program.parse();

const options = program.opts();
console.log(options);

async function loadMode(app, modeName, folder) {
let modeModule;
Expand Down Expand Up @@ -88,7 +87,7 @@ if (!options.noAuth) {

app.listen(options.port, () => {
console.log(
`\n${version.package}@${version.text} is serving '${options.folder}' at:\n${getNetworkAddressesList(
`\n${version.package}@${version.text} is serving '${options.folder}' as '${options.mode}' at:\n${getNetworkAddressesList(
"http",
options.port,
).join("\n")}`,
Expand Down

0 comments on commit c71e461

Please sign in to comment.