https://github.com/node-ci/nci-static-server
Static files server for nci
https://github.com/node-ci/nci-static-server
Last synced: 8 months ago
JSON representation
Static files server for nci
- Host: GitHub
- URL: https://github.com/node-ci/nci-static-server
- Owner: node-ci
- License: mit
- Created: 2016-01-09T11:35:44.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2021-04-05T20:26:21.000Z (almost 5 years ago)
- Last Synced: 2025-05-18T00:40:19.127Z (9 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# nci static server
Static files server for [nci](https://github.com/node-ci/nci).
[](https://www.npmjs.org/package/nci-static-server)
[](https://snyk.io/test/npm/nci-static-server)
## Node.js compatibility
This plugin requires node.js >= 10 to work.
## Installation
```sh
npm install nci-static-server
```
## Usage
To enable add this plugin to the `plugins` section at server config, set
locations which should be shared via http by setting `http.static` section e.g.:
```json
{
"plugins": [
"nci-static-server"
],
"http": {
"host": "127.0.0.1",
"port": 3000,
"url": "http://127.0.0.1:3000",
"static": {
"locations": [
{
"url": "/js/",
"root": "static/"
}
]
}
},
....
}
```
Location `root` resolves according to current working dirictory.
Example above will share all files from `current working dirictory/static/js/`
when access to `/js/` e.g. `current working dirictory/static/js/lib/jquery.js`
will be available by url `/js/lib/jquery.js`.
Location `url` also can be a regexp but then you need to use reader which
supports regexps e.g. with [nci yaml reader](https://github.com/node-ci/nci-yaml-reader)
server `config.yml` may looks like:
```yml
plugins:
- nci-static-server
http:
host: 127.0.0.1
port: 3000
url: http://127.0.0.1:3000
static:
locations:
- url: !!js/regexp ^/(js|css|fonts|images)/
root: static/
- url: !!js/regexp ^/projects/(\w|-)+/workspace(/)?
root: data/
#uncomment lines below to prevent directory listing
# options:
# showDir: false
```
first location shares all required static, the second one provides access to
content of project workspaces. Note that by default directory listing is
enabled.