@node-cli/static-server 4.1.1 → 4.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/logs.js +1 -1
- package/dist/logs.js.map +1 -1
- package/dist/server.js +6 -1
- package/dist/server.js.map +1 -1
- package/package.json +3 -3
package/dist/logs.js
CHANGED
package/dist/logs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/logs.ts"],"sourcesContent":["import type { FastifyPluginAsync } from \"fastify\";\nimport fastifyPlugin from \"fastify-plugin\";\nimport kleur from \"kleur\";\n\nconst plugin: FastifyPluginAsync = async (fastify): Promise<void> => {\n\tfastify.addHook(\"onResponse\", async (request, reply) => {\n\t\trequest.log.info(\n\t\t\tkleur.cyan(`${request.method} ${request.url} ${reply.statusCode}`),\n\t\t);\n\t});\n};\n\nexport default fastifyPlugin(plugin, {\n\tfastify: \"
|
|
1
|
+
{"version":3,"sources":["../src/logs.ts"],"sourcesContent":["import type { FastifyPluginAsync } from \"fastify\";\nimport fastifyPlugin from \"fastify-plugin\";\nimport kleur from \"kleur\";\n\nconst plugin: FastifyPluginAsync = async (fastify): Promise<void> => {\n\tfastify.addHook(\"onResponse\", async (request, reply) => {\n\t\trequest.log.info(\n\t\t\tkleur.cyan(`${request.method} ${request.url} ${reply.statusCode}`),\n\t\t);\n\t});\n};\n\nexport default fastifyPlugin(plugin, {\n\tfastify: \"5.x\",\n\tname: \"fastify-simple-logger\",\n});\n"],"names":["fastifyPlugin","kleur","plugin","fastify","addHook","request","reply","log","info","cyan","method","url","statusCode","name"],"mappings":"AACA,OAAOA,mBAAmB,iBAAiB;AAC3C,OAAOC,WAAW,QAAQ;AAE1B,MAAMC,SAA6B,OAAOC;IACzCA,QAAQC,OAAO,CAAC,cAAc,OAAOC,SAASC;QAC7CD,QAAQE,GAAG,CAACC,IAAI,CACfP,MAAMQ,IAAI,CAAC,GAAGJ,QAAQK,MAAM,CAAC,CAAC,EAAEL,QAAQM,GAAG,CAAC,CAAC,EAAEL,MAAMM,UAAU,EAAE;IAEnE;AACD;AAEA,eAAeZ,cAAcE,QAAQ;IACpCC,SAAS;IACTU,MAAM;AACP,GAAG"}
|
package/dist/server.js
CHANGED
|
@@ -49,7 +49,12 @@ if (config.flags.http2) {
|
|
|
49
49
|
cert
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
/*
|
|
53
|
+
* fastify@5.11.2 narrowed its HTTP overloads with `http2?: false`, so an
|
|
54
|
+
* options object carrying a `boolean` http2 no longer matches any of them.
|
|
55
|
+
* Build the server through the plain HTTP signature - as it has always
|
|
56
|
+
* resolved - and let the http2/https options through at runtime.
|
|
57
|
+
*/ const fastify = Fastify(fastifyOptions);
|
|
53
58
|
if (config.flags.logs) {
|
|
54
59
|
fastify.register(fastifyLogs);
|
|
55
60
|
}
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport path from \"node:path\";\nimport fastifyCache from \"@fastify/caching\";\nimport fastifyCompress from \"@fastify/compress\";\nimport fastifyCors from \"@fastify/cors\";\nimport fastifyStatic, { FastifyStaticOptions } from \"@fastify/static\";\nimport { Logger } from \"@node-cli/logger\";\nimport Fastify from \"fastify\";\nimport fs from \"fs-extra\";\nimport kleur from \"kleur\";\nimport open from \"open\";\nimport portfinder from \"portfinder\";\nimport { cert, key } from \"./certs.js\";\nimport fastifyLogs from \"./logs.js\";\nimport { config } from \"./parse.js\";\nimport { renderDirectories } from \"./templates/directories.js\";\nimport { renderNotFound } from \"./templates/not-found.js\";\n\nexport const logger = new Logger({\n\tboring: process.env.NODE_ENV === \"test\",\n});\n\nlet customPath = config.parameters[0];\nif (fs.pathExistsSync(customPath)) {\n\tcustomPath = path.resolve(customPath);\n} else {\n\tlogger.printErrorsAndExit([`Folder ${customPath} does not exist!`], 0);\n}\n\nconst fastifyOptions: {\n\
|
|
1
|
+
{"version":3,"sources":["../src/server.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport path from \"node:path\";\nimport fastifyCache from \"@fastify/caching\";\nimport fastifyCompress from \"@fastify/compress\";\nimport fastifyCors from \"@fastify/cors\";\nimport fastifyStatic, { FastifyStaticOptions } from \"@fastify/static\";\nimport { Logger } from \"@node-cli/logger\";\nimport Fastify, { FastifyServerOptions } from \"fastify\";\nimport fs from \"fs-extra\";\nimport kleur from \"kleur\";\nimport open from \"open\";\nimport portfinder from \"portfinder\";\nimport { cert, key } from \"./certs.js\";\nimport fastifyLogs from \"./logs.js\";\nimport { config } from \"./parse.js\";\nimport { renderDirectories } from \"./templates/directories.js\";\nimport { renderNotFound } from \"./templates/not-found.js\";\n\nexport const logger = new Logger({\n\tboring: process.env.NODE_ENV === \"test\",\n});\n\nlet customPath = config.parameters[0];\nif (fs.pathExistsSync(customPath)) {\n\tcustomPath = path.resolve(customPath);\n} else {\n\tlogger.printErrorsAndExit([`Folder ${customPath} does not exist!`], 0);\n}\n\nconst fastifyOptions: FastifyServerOptions & {\n\thttp2?: boolean;\n\thttps?: any;\n} = {\n\tdisableRequestLogging: true,\n};\n\nif (config.flags.logs) {\n\tfastifyOptions.logger = {\n\t\tlevel: \"info\",\n\t\ttransport: {\n\t\t\ttarget: \"pino-pretty\",\n\t\t\toptions: {\n\t\t\t\thideObject: true,\n\t\t\t\ttranslateTime: \"SYS:standard\",\n\t\t\t\tignore: \"pid,hostname,reqId,resTime,resTimeMs,level\",\n\t\t\t},\n\t\t},\n\t};\n}\n\nif (config.flags.http2) {\n\tfastifyOptions.http2 = true;\n\tfastifyOptions.https = { key, cert };\n}\n\n/*\n * fastify@5.11.2 narrowed its HTTP overloads with `http2?: false`, so an\n * options object carrying a `boolean` http2 no longer matches any of them.\n * Build the server through the plain HTTP signature - as it has always\n * resolved - and let the http2/https options through at runtime.\n */\nconst fastify = Fastify(fastifyOptions as FastifyServerOptions);\n\nif (config.flags.logs) {\n\tfastify.register(fastifyLogs);\n}\n\nif (config.flags.gzip) {\n\tfastify.register(fastifyCompress, {\n\t\tglobal: true,\n\t\tencodings: [\"gzip\", \"deflate\", \"br\", \"identity\"],\n\t});\n}\n\nif (config.flags.cors) {\n\tfastify.register(fastifyCors);\n}\n\nconst fastifyCacheOptions: {\n\texpiresIn?: number;\n\tserverExpiresIn?: number;\n\tprivacy?: any;\n} = {};\n\nif (config.flags.cache > 0) {\n\tfastifyCacheOptions.expiresIn = config.flags.cache;\n\tfastifyCacheOptions.serverExpiresIn = config.flags.cache;\n\tfastifyCacheOptions.privacy = \"public\";\n} else {\n\tfastifyCacheOptions.privacy = \"no-cache\";\n}\n\nfastify.register(fastifyCache, fastifyCacheOptions);\n\nconst staticOptions: FastifyStaticOptions = {\n\troot: customPath,\n};\nif (config.flags.dirs) {\n\tstaticOptions.list = {\n\t\tformat: \"html\",\n\t\trender: renderDirectories,\n\t};\n}\nfastify.register(fastifyStatic, staticOptions);\n\nfastify.setNotFoundHandler((_request, reply) => {\n\treply.code(404).type(\"text/html\").send(renderNotFound(config.flags.dirs));\n});\n\n/**\n * Run the server!\n */\nlet port: number,\n\taddress: string,\n\tportMessage = \"\";\nconst start = async () => {\n\ttry {\n\t\tport = await portfinder.getPortPromise({ port: Number(config.flags.port) });\n\t\tif (port !== config.flags.port) {\n\t\t\tportMessage = `\\n\\n${kleur.yellow(\n\t\t\t\t`Warning: port ${config.flags.port} was not available!`,\n\t\t\t)}`;\n\t\t\tconfig.flags.port = port;\n\t\t}\n\t\tconst listenOptions: { port?: number; host?: string } = {\n\t\t\tport: config.flags.port,\n\t\t};\n\t\tif (config.flags.host) {\n\t\t\tlistenOptions.host = config.flags.host;\n\t\t\taddress = config.flags.host;\n\t\t} else {\n\t\t\taddress = \"localhost\";\n\t\t}\n\t\tawait fastify.listen(listenOptions);\n\n\t\tconst url = `${config.flags.http2 ? \"https\" : \"http\"}://${address}:${\n\t\t\tconfig.flags.port\n\t\t}`;\n\t\tconst messages = [\n\t\t\t`${kleur.cyan(\"Static Server\")} is up and running!`,\n\t\t\t\"\",\n\t\t\t`${kleur.cyan(url)}`,\n\t\t\t\"\",\n\t\t\t`Hit CTRL+C to shut it down.${portMessage}`,\n\t\t];\n\n\t\tlogger.printBox(messages, { newLineAfter: false });\n\n\t\tif (config.flags.open) {\n\t\t\tawait open(url, {\n\t\t\t\twait: false,\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tfastify.log.error(error);\n\t\t// eslint-disable-next-line unicorn/no-process-exit\n\t\tprocess.exit(1);\n\t}\n};\nstart();\n"],"names":["path","fastifyCache","fastifyCompress","fastifyCors","fastifyStatic","Logger","Fastify","fs","kleur","open","portfinder","cert","key","fastifyLogs","config","renderDirectories","renderNotFound","logger","boring","process","env","NODE_ENV","customPath","parameters","pathExistsSync","resolve","printErrorsAndExit","fastifyOptions","disableRequestLogging","flags","logs","level","transport","target","options","hideObject","translateTime","ignore","http2","https","fastify","register","gzip","global","encodings","cors","fastifyCacheOptions","cache","expiresIn","serverExpiresIn","privacy","staticOptions","root","dirs","list","format","render","setNotFoundHandler","_request","reply","code","type","send","port","address","portMessage","start","getPortPromise","Number","yellow","listenOptions","host","listen","url","messages","cyan","printBox","newLineAfter","wait","error","log","exit"],"mappings":";AAEA,OAAOA,UAAU,YAAY;AAC7B,OAAOC,kBAAkB,mBAAmB;AAC5C,OAAOC,qBAAqB,oBAAoB;AAChD,OAAOC,iBAAiB,gBAAgB;AACxC,OAAOC,mBAA6C,kBAAkB;AACtE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,aAAuC,UAAU;AACxD,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,UAAU,OAAO;AACxB,OAAOC,gBAAgB,aAAa;AACpC,SAASC,IAAI,EAAEC,GAAG,QAAQ,aAAa;AACvC,OAAOC,iBAAiB,YAAY;AACpC,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,iBAAi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CAACS,KAAK,GAAG,UAAU,OAAO,GAAG,EAAE0B,QAAQ,CAAC,EAClElD,OAAOe,KAAK,CAACkC,IAAI,EAChB;QACF,MAAMW,WAAW;YAChB,GAAGlE,MAAMmE,IAAI,CAAC,iBAAiB,mBAAmB,CAAC;YACnD;YACA,GAAGnE,MAAMmE,IAAI,CAACF,MAAM;YACpB;YACA,CAAC,2BAA2B,EAAER,aAAa;SAC3C;QAEDhD,OAAO2D,QAAQ,CAACF,UAAU;YAAEG,cAAc;QAAM;QAEhD,IAAI/D,OAAOe,KAAK,CAACpB,IAAI,EAAE;YACtB,MAAMA,KAAKgE,KAAK;gBACfK,MAAM;YACP;QACD;IACD,EAAE,OAAOC,OAAO;QACfvC,QAAQwC,GAAG,CAACD,KAAK,CAACA;QAClB,mDAAmD;QACnD5D,QAAQ8D,IAAI,CAAC;IACd;AACD;AACAf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-cli/static-server",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"description": "A simple, zero-configuration, command line HTTP server to serve static files locally",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@fastify/static": "10.1.2",
|
|
39
39
|
"@node-cli/logger": "2.1.0",
|
|
40
40
|
"@node-cli/parser": "3.1.0",
|
|
41
|
-
"fastify": "5.
|
|
41
|
+
"fastify": "5.11.2",
|
|
42
42
|
"fastify-plugin": "6.0.0",
|
|
43
43
|
"fs-extra": "11.4.0",
|
|
44
44
|
"kleur": "4.1.5",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"@vitest/coverage-v8": "4.1.10",
|
|
54
54
|
"vitest": "4.1.10"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "4d8a6f9382ee80e62538a30b18c6544d30346162"
|
|
57
57
|
}
|