{"id":16384582,"url":"https://github.com/nashaofu/hserver-static","last_synced_at":"2025-06-18T20:33:09.626Z","repository":{"id":57267153,"uuid":"77836383","full_name":"nashaofu/hserver-static","owner":"nashaofu","description":"a hserver static file server middleware","archived":false,"fork":false,"pushed_at":"2020-01-06T01:55:54.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T02:18:53.262Z","etag":null,"topics":["fileserver","hserver-","hserver-middleware","http-server","static-server"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nashaofu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-02T13:45:39.000Z","updated_at":"2020-01-06T01:55:56.000Z","dependencies_parsed_at":"2022-08-26T13:41:07.303Z","dependency_job_id":null,"html_url":"https://github.com/nashaofu/hserver-static","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/nashaofu/hserver-static","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nashaofu%2Fhserver-static","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nashaofu%2Fhserver-static/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nashaofu%2Fhserver-static/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nashaofu%2Fhserver-static/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nashaofu","download_url":"https://codeload.github.com/nashaofu/hserver-static/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nashaofu%2Fhserver-static/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260629301,"owners_count":23038902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fileserver","hserver-","hserver-middleware","http-server","static-server"],"created_at":"2024-10-11T04:11:49.137Z","updated_at":"2025-06-18T20:33:04.609Z","avatar_url":"https://github.com/nashaofu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hserver-static\na hserver static file server middleware\n\n## example\n    'use strict';\n    const Hserver = require('hserver');\n    const Hstatic = require('hserver-static');\n\n    const port = 8081;\n    const app = new Hserver();\n\n    // logger\n    app.use(function (next) {\n        const start = new Date;\n        this.res.once('finish', () =\u003e {\n            const ms = new Date - start;\n            console.log('%s %s %s - time:%s', this.status, this.method, this.url, ms);\n        });\n        next();\n    });\n    // static middleware\n    app.use(Hstatic({\n        // 定义访问路径前缀\n        // default ''\n        router: '/',\n        // 定义根文件目录\n        // default '.'\n        root: 'www',\n        // 定义index文件\n        // default 'index.html'\n        index: 'index.html',\n        // 允许访问method ['GET', 'POST', 'HEAD', 'DELETE', 'PUT']\n        // default ['GET', 'HEAD']\n        method: ['GET', 'HEAD'],\n        // 是否启用文件gzip压缩 Array|true|false\n        // ['deflate', 'gzip']\n        // 为true时默认为['deflate', 'gzip']\n        // 为false时，关闭gzip压缩\n        // default false\n        zip: true,\n        // 缓存时间 time(s)|true|0\n        // 为true时，默认缓存时间为7200s\n        // 为0时不缓存\n        // default 0\n        cache: 7200,\n        // etag true|false\n        // default false\n        etag: true\n    }));\n    app.listen(port);\n    console.log(`Server is running at http://127.0.0.1:${port}/`);","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnashaofu%2Fhserver-static","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnashaofu%2Fhserver-static","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnashaofu%2Fhserver-static/lists"}