Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aminnairi/serve
Command-line interface for serving files.
https://github.com/aminnairi/serve
Last synced: about 5 hours ago
JSON representation
Command-line interface for serving files.
- Host: GitHub
- URL: https://github.com/aminnairi/serve
- Owner: aminnairi
- License: mit
- Created: 2021-02-01T22:52:55.000Z (almost 4 years ago)
- Default Branch: latest
- Last Pushed: 2021-02-06T12:18:24.000Z (almost 4 years ago)
- Last Synced: 2024-11-10T04:06:28.184Z (6 days ago)
- Language: JavaScript
- Homepage: https://npmjs.com/package/@aminnairi/serve
- Size: 207 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# @aminnairi/serve
Command-line interface for serving files.
[![Code Style](https://github.com/aminnairi/serve/workflows/Code%20Style/badge.svg)](https://github.com/aminnairi/serve/actions?query=workflow%3A%22Code+Style%22) [![Test](https://github.com/aminnairi/serve/workflows/Test/badge.svg)](https://github.com/aminnairi/serve/actions?query=workflow%3ATest) [![Package](https://github.com/aminnairi/serve/workflows/Package/badge.svg)](https://github.com/aminnairi/serve/actions?query=workflow%3APackage)
```console
$ npx @aminnairi/serve --folder client
Serving files from the client folder at http://127.0.0.1:8000. Hit CTRL+C at any time to stop.
```## Requirements
- [Node 14.0.0 or later](https://nodejs.org/en/)
- [NPM](https://www.npmjs.com/)## Usage
### NPX
```console
$ npx @aminnairi/serve --help
```### NPM
```console
$ npm install @aminnairi/serve
$ node ./node_modules/.bin/serve --help
```### Global
```console
$ sudo npm install --global @aminnairi/serve
$ serve --help
```### Docker
```console
$ docker run --interactive --tty --user node --workdir /home/node --volume "$PWD":/home/node --publish 8000:8000 node npx @aminnairi/serve --host 0.0.0.0 --port 8000
```### Docker Compose
```console
$ touch docker-compose.yaml
``````yaml
version: "3"services:
server:
image: node
user: node
working_dir: /home/node
command: npx @aminnairi/serve --host 0.0.0.0 --port 8000
ports:
- 8000:8000
volumes:
- .:/home/node
``````console
$ docker-compose up server
```## Examples
### Folder
*The folder from where to serve the static folder (default to the current folder).*
```console
$ serve --folder public
```### Host
*The host from which to listen (default to 127.0.0.1).*
```console
$ serve --host 0.0.0.0
```### Port
*The port from which to listen (default to 8000). Fail if not an integer.*
```console
$ serve --port 5000
```### Single-page application
*Whether to route all request to the current folder's index.html file (default to false).*
```console
$ serve --spa
```### Base
*Set a base prefix url (default to empty) useful for GitHub Pages for instance.*
```console
$ serve --base aminnairi
```### Verbose
*Display error message on the console instead of hidding them.*
```console
$ serve --verbose
```### Help
*Display the help in the console.*
```console
$ serve --help
```