# cfhs-js

> Complex HTTP File Server

Latest version **0.1.13** (published 2021-09-19) · GPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install cfhs-js
pnpm add cfhs-js
yarn add cfhs-js
bun add cfhs-js
```

Provides the commands `cfhs-js-ctl`, `cfhs-js-serverd`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.13 |
| Published | 2021-09-19 |
| First published | 2021-03-29 |
| Weekly downloads | 0 |
| License | GPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 59.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Neruthes |
| Maintainers | neruthes |

## Links

- npm: https://www.npmjs.com/package/cfhs-js
- Repository: https://github.com/neruthes/cfhs-js
- Homepage: https://github.com/neruthes/cfhs-js#readme
- Issues: https://github.com/neruthes/cfhs-js/issues
- npm.io page: https://npm.io/package/cfhs-js

## Recent versions

- 0.1.13 (latest) — 2021-09-19
- 0.1.12 — 2021-08-17
- 0.1.11 — 2021-04-19
- 0.1.10 — 2021-04-01
- 0.1.9 — 2021-04-01
- 0.1.8 — 2021-03-31
- 0.1.7 — 2021-03-31
- 0.1.6 — 2021-03-31
- 0.1.5 — 2021-03-31
- 0.1.4 — 2021-03-31
- 0.1.3 — 2021-03-29
- 0.1.2 — 2021-03-29
- 0.1.1 — 2021-03-29
- 0.1.0 — 2021-03-29

## README

# CFHS-js

Complex file HTTP server.

Early WIP.

## Features

- Authentication: UUID tokens are used to manage accessing.
- Multi-instance: As many instances as you want.
- Multi-directory: The directories do not have to be located inside one place.

## Installation

This project is at the early stage. Simplified installation should be added later.

Now supporting GNU/Linux. BSD users might see problems.

## Configuration

### Overview

All config files are stored in `~/.config/cfhs-js`.
It may contain multiple directories; each of them represent one instance.
Each instance has 3 files:

- `conf`
- `dirs`
- `tokens`

### Config File: `conf`

This is where main configuration options reside.
Now only the port number is configurable.

Example:

```
Port=1453
ServerName=Example HTTP File Server
UrlPrefix=http://127.0.0.1:1453
```

This is not shell script, so no need to quote or escape for space characters.

You have to write port number in `UrlPrefix` again, unless it is the default
port of the protocol specified afore. While this program is supposed to listen
at a harmless port, users might need to visit through Nginx which listens at
80 or 443, according to your specific setup.

### Config File: `dirs`

Write a list of directories to be shared. Use absolute paths.

Example:

```
/tmp/cfhs-default:abcd
/tmp/cfhs-new
```

Optionally append `:abcd` at the end of a line to let it appear as `abcd` in the
root index.
In the example, the 2 directories will appear as `abcd` and `cfhs-new` in the
root index.

### Config File: `tokens`

Users should not touch this file. The program manages tokens.

This file is a CSV with 5 columns:

Index   | Field Name        | Details
------- | ----------------- | -------
0       | Timestamp         | Timestamp of generation.
1       | Type              | Single uppercase letter. A for admin; V for visitor.
2       | Token             | UUID with hyphen.
3       | Path              | The path which this token is authorized to access.
4       | Expiry            | The expiry date, ISO 8601 format, initial 19 characters.

## Manage Instances

### Create

```
cfhs-js-ctl new MyInstanceName
```

This will create the instance configuration directory.

### Start & End Instances

```
cfhs-js-ctl start MyInstanceName
cfhs-js-ctl end MyInstanceName
```

You may start and stop instances with the 2 subcommands.

### Check Instance Status

```
cfhs-js-ctl status-all
```

## How Things Work

### Process Life Cycle

The program `cfhsctl` is a small script to manage configrations and processes.
It starts and ends `serverd.js` processes, which actually accepts HTTP requests.

Since this project is an early-stage WIP, you may prefer to use `serverd.js`
with manual configuration, instead of playing with `cfhsctl`.

### Tokens

Tokens include admin tokens and visitor tokens.
Admin tokens can be used to generate visitor tokens.

Admin tokens can access all directories and files,
but visitor tokens can only access the directories which they are authorized.

Both programs create tokens.

### Web User Session

When a user visits a page, the URL should include a token.
If the token is an admin token, or a visitor token with correct access at the path,
the user will be allowed to see the index of the directory or download the file.
When navigating from page to page, the token will be preserved in the URL.

## Copyright

Copyright (c) 2021 Neruthes.

Published under GNU GPLv2. See file `LICENSE`.

---
_Source: https://npm.io/package/cfhs-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
