# simple-files-server

> A Simple HTTP Server to serve static files.

Latest version **3.0.0** (published 2021-01-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-files-server
pnpm add simple-files-server
yarn add simple-files-server
bun add simple-files-server
```

Provides the commands `sfs`, `sf-server`, `simple-files-server`.

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2021-01-26 |
| First published | 2020-09-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Gabriel José |
| Maintainers | gabriel.jose |
| Keywords | static-server, files-server, server, no-dependencies |

## Links

- npm: https://www.npmjs.com/package/simple-files-server
- Repository: https://github.com/Gabriel-JM/simple-nodejs-static-server
- Homepage: https://github.com/Gabriel-JM/simple-nodejs-static-server#readme
- Issues: https://github.com/Gabriel-JM/simple-nodejs-static-server/issues
- npm.io page: https://npm.io/package/simple-files-server

## Recent versions

- 3.0.0 (latest) — 2021-01-26
- 2.2.0 — 2021-01-26
- 2.1.1 — 2021-01-26
- 2.0.2 — 2021-01-17
- 2.0.1 — 2021-01-17
- 2.0.0 — 2021-01-16
- 1.2.2 — 2020-12-20
- 1.2.1 — 2020-12-20
- 1.2.0 — 2020-12-20
- 1.1.2 — 2020-11-05
- 1.1.1 — 2020-10-10
- 1.1.0 — 2020-10-06
- 1.0.9 — 2020-09-29
- 1.0.8 — 2020-09-29
- 1.0.7 — 2020-09-29
- … 6 more at https://npm.io/package/simple-files-server/versions

## README

# Simple Files Server

An easy to use, static files server made in Node.js

## Use case
Its focused on serve static files like front-end files.

## How to use

### CLI
```bash
  <command> <source> <options>
```
- command: the command to execute the server, you can use one of those, `simple-files-server`, `sf-server`, `sfs`.
- source: `optional` file or folder to serve, the server will serve the file or search for the `index.html` file if source is a folder. `Default: ./`
- options:
  - port: `optional` the port to start the server. `Default: 3500`.
  - spa: `optional` a boolean value, if its is true the server will serve the index.html file if the request path wasn't for a file and no index.html file was found in the path, for example /about. `Default: false`.

### Programmatically
```js
const filesServer = require('simple-files-server')
const port = process.env.PORT || 3500

const server = filesServer({
  //Server Options
})

server.listen(port, /* Custom Log */)
```
### Server Options
- **source**: equal to `source` cli option.
- **spa**: equal to `spa` cli option.
- **mimeTypes**: `optional` mime types of files to serve, can be override with an `object` or use a `function` that will receive the default mime types as first parameter and the return of this function will be the new mime types options.

**Default MIME types:**
```js
{
  txt: 'text/plain',
  html: 'text/html',
  css: 'text/css',
  js: 'text/javascript',
  xml: 'application/xml',
  ts: 'application/typescript',
  json: 'application/json',
  pdf: 'application/pdf',
  jpg: 'image/jpeg',
  png: 'image/png',
  gif: 'image/gif',
  svg: 'image/svg+xml',
  ico: 'image/x-icon',
  otf: 'font/otf',
  ttf: 'font/ttf'
}
```

### Custom Log
By default, this function is `optional` and will show the default logs when start the server. But you can provide a function, which receive the `port` as first parameter, and write your own logs.

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