# static-server-nodejs

> Simple static server for Nodejs

Latest version **0.1.1** (published 2016-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install static-server-nodejs
pnpm add static-server-nodejs
yarn add static-server-nodejs
bun add static-server-nodejs
```

## 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.1 |
| Published | 2016-05-24 |
| First published | 2016-05-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alex Voronysnaky |
| Maintainers | belirafon |
| Keywords | simple, static, server |

## Links

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

## Recent versions

- 0.1.1 (latest) — 2016-05-24
- 0.1.0 — 2016-05-12

## README

# Static Server for NodeJS

[![Build Status](https://travis-ci.org/BelirafoN/static-server-nodejs.svg?branch=master)](https://travis-ci.org/BelirafoN/static-server-nodejs)
[![Code Climate](https://codeclimate.com/github/BelirafoN/static-server-nodejs/badges/gpa.svg)](https://codeclimate.com/github/BelirafoN/static-server-nodejs)
[![npm version](https://badge.fury.io/js/static-server-nodejs.svg)](https://badge.fury.io/js/static-server-nodejs)

## Available features 

1. No npm-dependencies;
2. HTTP-methods: `GET`, `HEAD`, `OPTIONS`;
2. CORS;
3. Support simple cache with `If-Modified-Since` header
4. Set any directory as public
5. Set any file as index-file for server and for subdirectories of public directory
6. Simple requests-log to console 
7. Ready to run out of box

## CLI Run 

```bash
node ./bin/nodess
``` 

or with npm

```bash
npm start
``` 

## CLI Parameters & Options

- `--help` - show help information about cli-configuration.
- `--port` or `-p` - port for listening. Default is `3000`
- `--public` or `-d` - public directory. Default is `./public`
- `--cors` - CORS support. Default is `false`
- `--cache-headers` - support simple cache with `If-Modified-Since` header. Default is `false`. 
- `--index-file` - name of custom index-file. Default is `index.html`.
- `--verbose` - print request-log to console. Default is `false`.

## Examples
```js
const createStaticServer = require('static-server-nodejs');
const path = require('path');
const PORT = process.env.NODESS_PORT || 3000;

let staticServer = createStaticServer(path.join(__dirname, './public'),{
    cors: true,
    cache: true,
    indexFile: 'index.html',
    verbose: true
})
    .listen(PORT, '127.0.0.1', () => {
        console.log(`Server run and listen on ${PORT} port.`);
    });
```

For examples, please, see `./examples/*` or tests `./test/*`.

## Tests 

Tests require [Mocha](https://mochajs.org/). 

```bash 
mocha ./tests
``` 

or with `npm` 

```bash
npm test 
```

Test coverage with [Istanbul](https://gotwarlost.github.io/istanbul/) 

```bash
npm run coverage
```

## Road map 

- extended cache-headers support
- gzip support
- support multipart/* 
- create npm-package 

## License 

Licensed under the MIT License

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