3.0.0 • Published 4 years ago
simple-files-server v3.0.0
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
<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 theindex.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
.
- port:
Programmatically
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 anobject
or use afunction
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:
{
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.
3.0.0
4 years ago
2.2.0
4 years ago
2.1.1
4 years ago
2.0.2
4 years ago
2.0.1
4 years ago
2.0.0
4 years ago
1.2.2
4 years ago
1.2.0
4 years ago
1.2.1
4 years ago
1.1.2
4 years ago
1.1.1
4 years ago
1.1.0
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.1.7
4 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.0
4 years ago