New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

hserver-static

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hserver-static

a hserver static file server middleware

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
4
-78.95%
Maintainers
1
Weekly downloads
 
Created
Source

hserver-static

a hserver static file server middleware

example

'use strict';
const Hserver = require('hserver');
const Hstatic = require('hserver-static');

const port = 8081;
const app = new Hserver();

// logger
app.use(function (next) {
    const start = new Date;
    this.res.once('finish', () => {
        const ms = new Date - start;
        console.log('%s %s %s - time:%s', this.status, this.method, this.url, ms);
    });
    next();
});
// static middleware
app.use(Hstatic({
    // 定义访问路径前缀
    // default ''
    router: '/',
    // 定义根文件目录
    // default '.'
    root: 'www',
    // 定义index文件
    // default 'index.html'
    index: 'index.html',
    // 允许访问method ['GET', 'POST', 'HEAD', 'DELETE', 'PUT']
    // default ['GET', 'HEAD']
    method: ['GET', 'HEAD'],
    // 是否启用文件gzip压缩 Array|true|false
    // ['deflate', 'gzip']
    // 为true时默认为['deflate', 'gzip']
    // 为false时,关闭gzip压缩
    // default false
    zip: true,
    // 缓存时间 time(s)|true|0
    // 为true时,默认缓存时间为7200s
    // 为0时不缓存
    // default 0
    cache: 7200,
    // etag true|false
    // default false
    etag: true
}));
app.listen(port);
console.log(`Server is running at http://127.0.0.1:${port}/`);

Keywords

hserver

FAQs

Package last updated on 30 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts