{"_id":"@node-static/node-static","_rev":"6-2baae5aa6ba1e5ea86d164316ca94fe9","name":"@node-static/node-static","dist-tags":{"latest":"0.10.0"},"versions":{"0.8.0":{"name":"@node-static/node-static","version":"0.8.0","keywords":["http","static","file","server"],"author":{"name":"Alexis Sellier","email":"alexis@cloudhead.io"},"license":"MIT","_id":"@node-static/node-static@0.8.0","maintainers":[{"name":"brettz9","email":"brettz9@yahoo.com"}],"contributors":[{"name":"Pablo Cantero","email":"pablo@pablocantero.com"},{"name":"Ionică Bizău","email":"bizauionica@gmail.com"},{"name":"Brett Zamir"}],"homepage":"https://github.com/node-static/node-static","bugs":{"url":"https://github.com/node-static/node-static/issues"},"c8":{"lines":100,"exclude":["dist","test"],"branches":100,"functions":100,"statements":100,"check-coverage":true},"bin":{"static":"bin/cli.js"},"dist":{"shasum":"51993d05f91d5635792fe798db97e05136c93b20","tarball":"https://registry.npmjs.org/@node-static/node-static/-/node-static-0.8.0.tgz","fileCount":24,"integrity":"sha512-H9ddqSIw+WDv6bcy8/x5uYr5EtJpWW4WP5Aqn2lbO73Hs2eEVH0JlMGlMDWhU3TNPMBDex/B2t0QT2wp4cVQpA==","signatures":[{"sig":"MEUCIQDo8I4QMnPNXBy6fQpTmv/QlvehyXTlqeoASd0Ujocw+AIgOaVW8n5Xd6clW7gPnntSM01UrvBxn6vWlrpzlLzZJoo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":106006},"main":"./lib/node-static.js","type":"module","engines":{"node":"^20.11.0 || >= 22.0.0"},"exports":{".":{"types":"./dist/lib/node-static.d.ts","import":"./lib/node-static.js","require":"./dist/node-static.cjs"}},"gitHead":"a034013fede302d856844cb99a3f2285e4da14bb","scripts":{"tsc":"tsc","gzip":"node test/gzip.js","lint":"eslint .","test":"c8 npm run mocha","build":"rollup -c && tsc -p tsconfig-prod.json","mocha":"mocha test/integration --parallel","start":"./bin/cli.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"brettz9","email":"brettz9@yahoo.com"},"repository":{"url":"git+ssh://git@github.com/node-static/node-static.git","type":"git"},"_npmVersion":"11.6.2","description":"simple, compliant file streaming module for node","directories":{"test":"test","example":"examples"},"_nodeVersion":"22.16.0","dependencies":{"mime":"^3.0.0","colors":"1.4.0","minimatch":"^9.0.0","is-hidden-file":"^1.1.2","command-line-basics":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","chai":"^6.2.0","mocha":"^11.7.4","eslint":"^9.37.0","rollup":"^4.52.4","globals":"^16.4.0","@eslint/js":"^9.37.0","node-fetch":"^2.6.6","typescript":"^5.9.3","@types/chai":"^5.2.2","@types/mime":"^3.0.4","@types/node":"^24.7.2","@types/mocha":"^10.0.10","@types/node-gzip":"^1.1.3","@types/node-fetch":"^2.6.13"},"_npmOperationalInternal":{"tmp":"tmp/node-static_0.8.0_1761821777866_0.5274043305306568","host":"s3://npm-registry-packages-npm-production"}},"0.8.1":{"name":"@node-static/node-static","version":"0.8.1","keywords":["http","static","file","server"],"author":{"name":"Alexis Sellier","email":"alexis@cloudhead.io"},"license":"MIT","_id":"@node-static/node-static@0.8.1","maintainers":[{"name":"brettz9","email":"brettz9@yahoo.com"}],"contributors":[{"name":"Pablo Cantero","email":"pablo@pablocantero.com"},{"name":"Ionică Bizău","email":"bizauionica@gmail.com"},{"name":"Brett Zamir"}],"homepage":"https://github.com/node-static/node-static","bugs":{"url":"https://github.com/node-static/node-static/issues"},"c8":{"lines":100,"exclude":["dist","test"],"branches":100,"functions":100,"statements":100,"check-coverage":true},"bin":{"static":"bin/cli.js"},"dist":{"shasum":"b41422968b6fbd135723ca4d28efd9cfa3cc0574","tarball":"https://registry.npmjs.org/@node-static/node-static/-/node-static-0.8.1.tgz","fileCount":24,"integrity":"sha512-/vTCxhRFfust3dqUKhoqjWoPAbraEjdkJcWoqIfI440Z3yXP9bjcR+Mpb/w4fgCbh0aUPUWfxHKkAOtfpC728w==","signatures":[{"sig":"MEUCIQCV0dCgtvYtF84CsXjO/2ev9ucbIXC7s6mzsN/n3qgBkwIgVRqX/DrHmy5tFumdxeyIi9oNVuh9fq+G2YzXy3ZWYxE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":106526},"main":"./lib/node-static.js","type":"module","_from":"file:node-static-node-static-0.8.1.tgz","engines":{"node":"^20.11.0 || >= 22.0.0"},"exports":{".":{"types":"./dist/lib/node-static.d.ts","import":"./lib/node-static.js","require":"./dist/node-static.cjs"}},"scripts":{"tsc":"tsc","gzip":"node test/gzip.js","lint":"eslint .","test":"npm run gzip && c8 npm run mocha","build":"rollup -c && tsc -p tsconfig-prod.json","mocha":"mocha test/integration --parallel","start":"./bin/cli.js"},"_npmUser":{"name":"brettz9","email":"brettz9@yahoo.com"},"_resolved":"/private/var/folders/2n/_szg3q3d15n9mn2jd_q91cym0000gn/T/08e78a6b5bd0d0c8cf4a5b0db171e75d/node-static-node-static-0.8.1.tgz","_integrity":"sha512-/vTCxhRFfust3dqUKhoqjWoPAbraEjdkJcWoqIfI440Z3yXP9bjcR+Mpb/w4fgCbh0aUPUWfxHKkAOtfpC728w==","repository":{"url":"git+ssh://git@github.com/node-static/node-static.git","type":"git"},"_npmVersion":"11.6.2","description":"simple, compliant file streaming module for node","directories":{"test":"test","example":"examples"},"_nodeVersion":"22.16.0","dependencies":{"mime":"^3.0.0","colors":"1.4.0","minimatch":"^9.0.0","is-hidden-file":"^1.1.2","command-line-basics":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","chai":"^6.2.0","mocha":"^11.7.4","eslint":"^9.37.0","rollup":"^4.52.4","globals":"^16.4.0","@eslint/js":"^9.37.0","node-fetch":"^2.6.6","typescript":"^5.9.3","@types/chai":"^5.2.2","@types/mime":"^3.0.4","@types/node":"^24.7.2","@types/mocha":"^10.0.10","@types/node-gzip":"^1.1.3","@types/node-fetch":"^2.6.13"},"_npmOperationalInternal":{"tmp":"tmp/node-static_0.8.1_1762831129783_0.698440145928986","host":"s3://npm-registry-packages-npm-production"}},"0.9.0":{"name":"@node-static/node-static","version":"0.9.0","keywords":["http","static","file","server"],"author":{"name":"Alexis Sellier","email":"alexis@cloudhead.io"},"license":"MIT","_id":"@node-static/node-static@0.9.0","maintainers":[{"name":"brettz9","email":"brettz9@yahoo.com"}],"contributors":[{"name":"Pablo Cantero"},{"name":"Ionică Bizău","email":"bizauionica@gmail.com"},{"name":"Brett Zamir"}],"homepage":"https://github.com/node-static/node-static","bugs":{"url":"https://github.com/node-static/node-static/issues"},"c8":{"lines":100,"exclude":["dist","test"],"branches":100,"functions":100,"statements":100,"check-coverage":true},"bin":{"static":"bin/cli.js"},"dist":{"shasum":"e00c60ce078345968ef6b6dd25a80f8591e002d4","tarball":"https://registry.npmjs.org/@node-static/node-static/-/node-static-0.9.0.tgz","fileCount":24,"integrity":"sha512-3bP+qJ3YC3Vhg+vEBIgie7ACPy1w1AfFokQ72mrAfKc6w5dFfKqtcEQunc3u89nWivgQZvmFQBz7Zuwz7J2H1Q==","signatures":[{"sig":"MEUCIDLA4abOrOtmzX3Cjrgl7tyA18DB2ugSnOgz2Y4Le8vLAiEA7j7ciOrKG/QvyVQKpyYWAWMmc8Y2cZQ4ncc5SFOuyLw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":107084},"main":"./lib/node-static.js","type":"module","engines":{"node":"^22.0.0"},"exports":{".":{"types":"./dist/lib/node-static.d.ts","import":"./lib/node-static.js","require":"./dist/node-static.cjs"}},"gitHead":"9c6d2617141f92177608e15546bdab3f5de05498","scripts":{"tsc":"tsc","gzip":"node test/gzip.js","lint":"eslint .","test":"npm run gzip && c8 npm run mocha","build":"rollup -c && tsc -p tsconfig-prod.json","mocha":"mocha test/integration --parallel","start":"./bin/cli.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"brettz9","email":"brettz9@yahoo.com"},"repository":{"url":"git+ssh://git@github.com/node-static/node-static.git","type":"git"},"_npmVersion":"11.18.0","description":"simple, compliant file streaming module for node","directories":{"test":"test","example":"examples"},"_nodeVersion":"22.16.0","allowScripts":{"fsevents@2.3.3":true,"is-hidden-file@1.1.2":true},"dependencies":{"mime":"^3.0.0","minimatch":"^10.2.6","picocolors":"^1.1.1","is-hidden-file":"^1.1.2","command-line-basics":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^12.0.0","chai":"^6.2.2","mocha":"^11.7.6","eslint":"^10.8.0","rollup":"^4.62.3","globals":"^17.8.0","@eslint/js":"^10.0.1","node-fetch":"^2.6.6","typescript":"^7.0.2","@types/chai":"^5.2.3","@types/mime":"^3.0.4","@types/node":"^26.1.2","@types/mocha":"^10.0.10","@types/node-gzip":"^1.1.3","@types/node-fetch":"^2.6.13"},"_npmOperationalInternal":{"tmp":"tmp/node-static_0.9.0_1785200333748_0.4449734601271058","host":"s3://npm-registry-packages-npm-production"}},"0.9.1":{"name":"@node-static/node-static","version":"0.9.1","keywords":["http","static","file","server"],"author":"Alexis Sellier <alexis@cloudhead.io>","license":"MIT","_id":"@node-static/node-static@0.9.1","maintainers":[{"name":"brettz9","email":"brettz9@yahoo.com"}],"contributors":["Pablo Cantero","Ionică Bizău <bizauionica@gmail.com>","Brett Zamir"],"homepage":"https://github.com/node-static/node-static","bugs":{"url":"https://github.com/node-static/node-static/issues"},"c8":{"lines":100,"exclude":["dist","test"],"branches":100,"functions":100,"statements":100,"check-coverage":true},"bin":{"static":"bin/cli.js"},"dist":{"shasum":"700ef0a21e4f7210ba75662f9c5374f1c17e5ee8","tarball":"https://registry.npmjs.org/@node-static/node-static/-/node-static-0.9.1.tgz","fileCount":24,"integrity":"sha512-DIsY7EiiCpVk1C8LdqZGCmvrshBKDTgCiSiutUn4v1qp2wXogdsxovKhkOfKuBUtb82BI3AAKgIJm+uL7zeysA==","signatures":[{"sig":"MEUCIAgb+SPwExHaF9Sr/4UUz30wt8fdFfcMV6+NpDQLTgW/AiEAjDnZT8lXrJb2T0nL2K4ABiOWHTXFb4JCFYfufSzXrIg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":107115},"main":"./lib/node-static.js","type":"module","engines":{"node":"^22.0.0 || >= 24.0.0"},"exports":{".":{"types":"./dist/lib/node-static.d.ts","import":"./lib/node-static.js","require":"./dist/node-static.cjs"}},"scripts":{"tsc":"tsc","gzip":"node test/gzip.js","lint":"eslint .","test":"npm run gzip && c8 npm run mocha","build":"rollup -c && tsc -p tsconfig-prod.json","mocha":"mocha test/integration --parallel","start":"./bin/cli.js"},"_npmUser":{"name":"brettz9","email":"brettz9@yahoo.com"},"repository":{"url":"git+ssh://git@github.com/node-static/node-static.git","type":"git"},"description":"simple, compliant file streaming module for node","directories":{"test":"test","example":"examples"},"_nodeVersion":"26.0.0","allowScripts":{"fsevents@2.3.3":true,"is-hidden-file@1.1.2":true},"dependencies":{"mime":"^3.0.0","minimatch":"^10.2.6","picocolors":"^1.1.1","is-hidden-file":"^1.1.2","command-line-basics":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^12.0.0","chai":"^6.2.2","mocha":"^11.7.6","eslint":"^10.8.0","rollup":"^4.62.3","globals":"^17.8.0","@eslint/js":"^10.0.1","node-fetch":"^2.6.6","typescript":"^7.0.2","@types/chai":"^5.2.3","@types/mime":"^3.0.4","@types/node":"^26.1.2","@types/mocha":"^10.0.10","@types/node-gzip":"^1.1.3","@types/node-fetch":"^2.6.13"},"_npmOperationalInternal":{"tmp":"tmp/node-static_0.9.1_1787602590760_0.1217750521397496","host":"s3://npm-registry-packages-npm-production"}},"0.9.2":{"name":"@node-static/node-static","version":"0.9.2","keywords":["http","static","file","server"],"author":"Alexis Sellier <alexis@cloudhead.io>","license":"MIT","_id":"@node-static/node-static@0.9.2","maintainers":[{"name":"brettz9","email":"brettz9@yahoo.com"}],"contributors":["Pablo Cantero","Ionică Bizău <bizauionica@gmail.com>","Brett Zamir"],"homepage":"https://github.com/node-static/node-static","bugs":{"url":"https://github.com/node-static/node-static/issues"},"c8":{"lines":100,"exclude":["dist","test"],"branches":100,"functions":100,"statements":100,"check-coverage":true},"bin":{"static":"bin/cli.js"},"dist":{"shasum":"1b31908386cd59527edbb7115912f7df9a1d1836","tarball":"https://registry.npmjs.org/@node-static/node-static/-/node-static-0.9.2.tgz","fileCount":26,"integrity":"sha512-6Xg7tF1QiT9Kcf97aIjmo3eTRuAeUHSgiAjXwhl4CD5lypfP9NZwWIPSIPCeI95EjlsSrdy+jPpCMqEE48bdGA==","signatures":[{"sig":"MEQCIAsui86nkvC4OlujoH6RxiMOc36NtAZKRa4tWe/bkMpFAiB+yT9VF/JdBECCx+3i+7SqSi8kYcuX7BoXSsExqfJELA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEQCIDeqllRd7A6UM/O1OEAtICvcRqrDN1IXfpvE6rJ4UjpkAiB7OIKq0dcO50V67d7vmpSdStkxMxO1fmSNQsaynhc8yg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":110361},"main":"./lib/node-static.js","type":"module","engines":{"node":"^22.0.0 || >= 24.0.0"},"exports":{".":{"types":"./dist/lib/node-static.d.ts","import":"./lib/node-static.js","require":"./dist/node-static.cjs"}},"scripts":{"tsc":"tsc","gzip":"node test/gzip.js","lint":"eslint .","test":"npm run gzip && c8 npm run mocha","build":"rollup -c && tsc -p tsconfig-prod.json","mocha":"mocha test/integration --parallel","start":"./bin/cli.js"},"_npmUser":{"name":"brettz9","email":"brettz9@yahoo.com"},"repository":{"url":"git+ssh://git@github.com/node-static/node-static.git","type":"git"},"description":"simple, compliant file streaming module for node","directories":{"test":"test","example":"examples"},"allowScripts":{"fsevents@2.3.3":true,"is-hidden-file@1.1.2":true},"dependencies":{"mime":"^3.0.0","minimatch":"^10.2.6","picocolors":"^1.1.1","is-hidden-file":"^1.1.2","command-line-basics":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^12.0.0","chai":"^6.2.2","mocha":"^11.7.6","eslint":"^10.8.0","rollup":"^4.62.3","globals":"^17.8.0","@eslint/js":"^10.0.1","node-fetch":"^2.6.6","typescript":"^7.0.2","@types/chai":"^5.2.3","@types/mime":"^3.0.4","@types/node":"^26.1.2","@types/mocha":"^10.0.10","@types/node-gzip":"^1.1.3","@types/node-fetch":"^2.6.13"},"_npmOperationalInternal":{"tmp":"tmp/node-static_0.9.2_1789009055886_0.6455568793085513","host":"s3://npm-registry-packages-npm-production"}},"0.10.0":{"c8":{"lines":100,"exclude":["dist","test"],"branches":100,"functions":100,"statements":100,"check-coverage":true},"_id":"@node-static/node-static@0.10.0","bin":{"static":"bin/cli.js"},"bugs":{"url":"https://github.com/node-static/node-static/issues"},"dist":{"shasum":"49ccbfa69e31f9eeb8997be1b3667bb08a5d47d6","tarball":"https://registry.npmjs.org/@node-static/node-static/-/node-static-0.10.0.tgz","fileCount":24,"integrity":"sha512-trpk0vo1X5aGhpvGmhzoknMG573/868eSHXS/5m7AjZ5G7HCsI2f7w/UOpz6ldicQvgaWWDZmc6ZZJATI2RQ4g==","signatures":[{"sig":"MEYCIQCMpZJxAy7HAcrfa4fR70IOE6ncJvfzz3IIL4q8jYywnAIhALo6IRBJr1fQZBwk9dhq7LNVF9tdkH46J8zYX8/Ta/Ky","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAl9yS3Rv5PEI5YNiShmlE08fcNgrSlSwy/Tx0LPNFNfAiEAp3+oaUf8laqnJXY7Ujp1B5VSBz4EzCgg+AHlIdqPwow="}],"unpackedSize":110372},"main":"./lib/node-static.js","name":"@node-static/node-static","type":"module","author":{"name":"Alexis Sellier","email":"alexis@cloudhead.io"},"engines":{"node":"^22.0.0 || >= 24.0.0"},"exports":{".":{"types":"./dist/lib/node-static.d.ts","import":"./lib/node-static.js","require":"./dist/node-static.cjs"}},"gitHead":"59bbb6a4c5018fb157c83ab7ec36d8fe4a7cf5d2","license":"MIT","scripts":{"tsc":"tsc","gzip":"node test/gzip.js","lint":"eslint .","stop":"kill -9 $(lsof -ti tcp:8080)","test":"npm run gzip && c8 npm run mocha","build":"rollup -c && tsc -p tsconfig-prod.json","mocha":"mocha test/integration --parallel","start":"./bin/cli.js","prepublishOnly":"npm run tsc && npm run build"},"version":"0.10.0","_npmUser":{"name":"brettz9","email":"brettz9@yahoo.com"},"homepage":"https://github.com/node-static/node-static","keywords":["http","static","file","server"],"repository":{"url":"git+ssh://git@github.com/node-static/node-static.git","type":"git"},"_npmVersion":"11.19.0","description":"simple, compliant file streaming module for node","directories":{"test":"test","example":"examples"},"maintainers":[{"name":"brettz9","email":"brettz9@yahoo.com"}],"_nodeVersion":"26.8.1","allowScripts":{"fsevents@2.3.3":true,"is-hidden-file@1.1.2":true},"contributors":[{"name":"Pablo Cantero"},{"name":"Ionică Bizău","email":"bizauionica@gmail.com"},{"name":"Brett Zamir"}],"dependencies":{"mime":"^3.0.0","minimatch":"^10.2.6","picocolors":"^1.1.1","@types/mime":"^3.0.4","is-hidden-file":"^1.1.2","command-line-basics":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^12.0.0","chai":"^6.2.2","mocha":"^12.0.1","eslint":"^10.10.0","rollup":"^4.63.3","globals":"^17.12.0","@eslint/js":"^10.0.1","node-fetch":"^2.6.6","typescript":"^7.0.2","@types/chai":"^5.2.3","@types/node":"^26.1.2","@types/mocha":"^10.0.10","@types/node-gzip":"^1.1.3","@types/node-fetch":"^2.6.13"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/node-static_0.10.0_1789634023776_0.6377250348927352"}}},"time":{"created":"2025-10-30T10:56:17.744Z","modified":"2026-09-17T08:33:44.078Z","0.8.0":"2025-10-30T10:56:18.088Z","0.8.1":"2025-11-11T03:18:49.990Z","0.9.0":"2026-07-28T00:58:53.895Z","0.9.1":"2026-08-24T20:16:30.888Z","0.9.2":"2026-09-10T02:57:35.982Z","0.10.0":"2026-09-17T08:33:43.856Z"},"bugs":{"url":"https://github.com/node-static/node-static/issues"},"author":{"name":"Alexis Sellier","email":"alexis@cloudhead.io"},"license":"MIT","homepage":"https://github.com/node-static/node-static","keywords":["http","static","file","server"],"repository":{"url":"git+ssh://git@github.com/node-static/node-static.git","type":"git"},"description":"simple, compliant file streaming module for node","contributors":[{"name":"Pablo Cantero"},{"name":"Ionică Bizău","email":"bizauionica@gmail.com"},{"name":"Brett Zamir"}],"maintainers":[{"name":"brettz9","email":"brettz9@yahoo.com"}],"readme":"# @node-static/node-static\n\n[![Node.js CI status](http://github.com/node-static/node-static/workflows/Node.js%20CI/badge.svg)](https://github.com/node-static/node-static/actions)\n\n> a simple, *rfc 2616 compliant* file streaming module for [node](http://nodejs.org)\n\n@node-static/node-static understands and supports *conditional GET* and *HEAD* requests.\n@node-static/node-static is a maintained fork of node-static which was inspired by some of the other static-file serving modules out\nthere, such as node-paperboy and antinode.\n\n## Installation\n\n```sh\n$ npm install @node-static/node-static\n```\n\n## Set-up\n\n### ESM\n\n```js\nimport {Server, version, mime} from '@node-static/node-static';\n\n// OR:\n// import * as statik from '@node-static/node-static';\n```\n\n### CommonJS\n\n```js\nconst statik = require('@node-static/node-static');\n```\n\n## Usage\n\n```js\nimport http from 'node:http';\n\n//\n// Create a @node-static/node-static server instance to serve the './public' folder\n//\nconst file = new statik.Server('./public');\n\nhttp.createServer(function (request, response) {\n    request.addListener('end', function () {\n        //\n        // Serve files!\n        //\n        file.serve(request, response);\n    }).resume();\n}).listen(8080);\n```\n\n## API\n\n### Creating a node-static Server\n\nCreating a file server instance is as simple as:\n\n```js\nnew statik.Server();\n```\n\nThis will serve files in the current directory. If you want to serve files in\na specific directory, pass it as the first argument:\n\n```js\nnew statik.Server('./public');\n```\n\nYou can also specify how long the client is supposed to cache the files\n@node-static/node-static serves:\n\n```js\nnew statik.Server('./public', { cache: 3600 });\n```\n\nThis will set the `Cache-Control` header, telling clients to cache the file for\nan hour. This is the default setting.\n\n### Serving files under a directory\n\nTo serve files under a directory, simply call the `serve` method on a `Server`\ninstance, passing it the HTTP request and response object:\n\n```js\nimport http from 'node:http';\nimport * as statik from '@node-static/node-static';\n\nconst fileServer = new statik.Server('./public');\n\nhttp.createServer(function (request, response) {\n    request.addListener('end', function () {\n        fileServer.serve(request, response);\n    }).resume();\n}).listen(8080);\n```\n\n### Serving specific files\n\nIf you want to serve a specific file, like an error page for example, use the\n`serveFile` method:\n\n```js\nfileServer.serveFile('/error.html', 500, {}, request, response);\n```\n\nThis will serve the `error.html` file, from under the file root directory, with\na `500` status code.\nFor example, you could serve an error page, when the initial request wasn't\nfound:\n\n```js\nhttp.createServer(function (request, response) {\n    request.addListener('end', function () {\n        fileServer.serve(request, response, function (e, res) {\n            if (e && (e.status === 404)) { // If the file wasn't found\n                fileServer.serveFile(\n                    '/not-found.html', 404, {}, request, response\n                );\n            }\n        });\n    }).resume();\n}).listen(8080);\n```\n\nMore on intercepting errors below.\n\n### Transforming text files\n\nIf you wish to apply a transform to text files before they are streamed in\nresponse, you can supply a `transform` callback which returns a `stream`\n`Transform`.\n\nFor example, if we wished to upper-case everything in text content:\n\n```js\nimport {Transform} from 'stream';\n\nconst server = http.createServer((req, res) => {\n    const s = new statik.Server(__dirname + '/public', {\n        transform (fileString, pathname, req, res) {\n            return new Transform({\n                transform(chunk, _enc, cb) {\n                    // Supply the transformed data as the second argument\n                    cb(null, chunk.toString().toUpperCase());\n                }\n            });\n        }\n    });\n    s.serve(req, res);\n}).listen(9010);\n```\n\n### Serving custom directory\n\n```js\nconst fileServer = new statik.Server(__dirname + '/public', {\n    directoryCallback (pathname, req, res) {\n        res.writeHead(200, {\n            'Content-Type': 'text/html'\n        });\n        res.end(`Hi <b>${basename(pathname)}</b>!`);\n\n        // You could add a listing of files by `readdir` here\n    }\n});\n```\n\n### Intercepting errors & Listening\n\nAn optional callback can be passed as last argument, it will be called every\ntime a file has been served successfully, or if there was an error serving the\nfile:\n\n```js\nimport http from 'node:http';\nimport * as statik from '@node-static/node-static';\n\nconst fileServer = new statik.Server('./public');\n\nhttp.createServer(function (request, response) {\n    request.addListener('end', function () {\n        fileServer.serve(request, response, function (err, result) {\n            if (err) { // There was an error serving the file\n                console.error(\n                    \"Error serving \" + request.url + \" - \" + err.message\n                );\n\n                // Respond to the client\n                response.writeHead(err.status, err.headers);\n                response.end();\n            }\n        });\n    }).resume();\n}).listen(8080);\n```\n\nNote that if you pass a callback, and there is an error serving the file,\n@node-static/node-static *will not* respond to the client. This gives you\nthe opportunity\nto re-route the request, or handle it differently.\n\nFor example, you may want to interpret a request as a static request, but if\nthe file isn't found, send it to an application.\n\nIf you only want to *listen* for errors, you can use *event listeners*:\n\n```js\nfileServer.serve(request, response).addListener('error', function (err) {\n    console.error(\"Error serving \" + request.url + \" - \" + err.message);\n});\n```\n\nWith this method, you don't have to explicitly send the response back, in case\nof an error.\n\n### Options when creating an instance of `Server`\n\n#### `cache` (Default: `3600`)\n\nSets the `Cache-Control` header.\n\nexample: `{ cache: 7200 }` will set the max-age for all files to 7200 seconds\nexample: `{ cache: {'**/*.css': 300}}` will set the max-age for all CSS files to 5 minutes.\n\nPassing a number will set the cache duration to that number of seconds.\nPassing `false` will disable the `Cache-Control` header.\nPassing a object with [minimatch glob pattern](https://github.com/isaacs/minimatch)\nkeys and number values will set cache max-age for any matching paths.\n\n#### `serverInfo` (Default: `node-static/{version}`)\n\nSets the `Server` header.\n\nexample: `{ serverInfo: \"myserver\" }`\n\n#### `headers` (Default: `{}`)\n\nSets response headers.\n\nexample: `{ headers: { 'X-Hello': 'World!' } }`\n\n#### `gzip` (Default: `false`)\n\nEnable support for sending compressed responses.  This will enable a check for\na file with the same name plus '.gz' in the same folder.  If the compressed\nfile is found and the client has indicated support for gzip file transfer,\nthe contents of the .gz file will be sent in place of the uncompressed file\nalong with a `Content-Encoding: gzip` header to inform the client the data has\nbeen compressed.\n\nexample: `{ gzip: true }`\nexample: `{ gzip: /^\\/text/ }`\n\nPassing `true` will enable this check for all files.\n\nPassing a `RegExp` instance will only enable this check if the content-type of\nthe respond would match that `RegExp` using its `test()` method.\n\nFor cases where a gzip file is older than the source file, you can\nlisten for warnings:\n\n```js\nconst gzipFileServer = new statik.Server(__dirname + '/public', {\n    gzip: true\n});\ngzipFileServer.on(\n    'warn',\n    (warning, file, statMtime, gzStatMtime) => {\n        if (warning === 'Gzipped version is older than source file') {\n            // One could append an extension and create the gzip file here\n            console.log(file);\n        }\n    }\n);\n```\n\n#### `gzipOnly` (Default: `undefined`)\n\nThe default behavior is to require checking of a source file's existence.\nIf you want to allow gzipped files without source files, set\n`gzipOnly` to `allow`. If you want to go further and require that source\nfiles not be present for gzipped equivalents, then set `gzipOnly` to\n`require`.\n\n#### `gzipAuto` (Default: `undefined`)\n\nIf set, `gzipAuto` will trigger automatic gzipping of resources.\n\nThis will follow the settings of `gzip` to determine which files should be\ngzipped.\n\n#### `indexFile` (Default: `index.html`)\n\nChoose a custom index file when serving up directories.\n\nexample: `{ indexFile: \"index.htm\" }`\n\n#### `defaultExtension` (Default: `null`)\n\nChoose a default extension when serving files.\nA request to '/myFile' would check for a `myFile` folder (first) then a\n`myFile.html` (second).\n\nexample: `{ defaultExtension: \"html\" }`\n\n### Listening for emitted warnings\n\nCertain warnings are not logged to console but instead may be listened for.\n\n```js\nfileServer.on('warn', (msg) => {\n    console.log(msg);\n});\n```\n\n## Command Line Interface\n\n`@node-static/node-static` also provides a CLI.\n\n```text\n--port, -p          TCP port at which the files will be served                        [default: 8080]\n--host-address, -a  the local network interface at which to listen                    [default: \"127.0.0.1\"]\n--cache, -c         \"Cache-Control\" header setting, defaults to 3600\n--version, -v       @node-static/node-static version\n--headers, -H       additional headers (in JSON format)\n--header-file, -f   JSON file of additional headers\n--gzip, -z          enable compression (tries to serve file of same name plus '.gz')\n--spa               Serve the content as a single page app by redirecting all\n                    non-file requests to the index HTML file.\n--indexFile, -i     Specify a custom index file when serving up directories.          [default: \"index.html\"]\n--help, -h          display this help message\n```\n\n### Example Usage\n\n```sh\n# serve up the current directory\n$ static\nserving \".\" at http://127.0.0.1:8080\n\n# serve up a different directory\n$ static public\nserving \"public\" at http://127.0.0.1:8080\n\n# specify additional headers (this one is useful for development)\n$ static -H '{\"Cache-Control\": \"no-cache, must-revalidate\"}'\nserving \".\" at http://127.0.0.1:8080\n\n# set cache control max age\n$ static -c 7200\nserving \".\" at http://127.0.0.1:8080\n\n# expose the server to your local network\n$ static -a 0.0.0.0\nserving \".\" at http://0.0.0.0:8080\n\n# show help message, including all options\n$ static -h\n```\n","readmeFilename":"README.md"}