@gjsify/example-node-express-webserver 0.4.29 → 0.4.31

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.
@@ -326,7 +326,7 @@ t.exports=vary,t.exports.append=append;var n=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;fu
326
326
  * Copyright(c) 2014-2015 Douglas Christopher Wilson
327
327
  * MIT Licensed
328
328
  */
329
- var n=Ut(),r=k(),i=x()(`express`),a=_t(),o=vt(),s=u(`node:http`),c=le(),l=J(),d=u(`node:path`),p=u(`node:path`).isAbsolute,m=T(),h=Wt().sign,g=Q().normalizeType,_=Q().normalizeTypes,v=Q().setCharset,y=Gt(),b=Kt(),S=d.extname,w=d.resolve,E=qt();let{Buffer:D}=u(`node:buffer`);var O=Object.create(s.ServerResponse.prototype);t.exports=O,O.status=function status(e){if(!Number.isInteger(e))throw TypeError(`Invalid status code: ${JSON.stringify(e)}. Status code must be an integer.`);if(e<100||e>999)throw RangeError(`Invalid status code: ${JSON.stringify(e)}. Status code must be greater than 99 and less than 1000.`);return this.statusCode=e,this},O.links=function(e){var t=this.get(`Link`)||``;return t&&(t+=`, `),this.set(`Link`,t+Object.keys(e).map(function(t){return Array.isArray(e[t])?e[t].map(function(e){return`<${e}>; rel="${t}"`}).join(`, `):`<${e[t]}>; rel="${t}"`}).join(`, `))},O.send=function send(e){var t=e,n,r=this.req,i,a=this.app;switch(typeof t){case`string`:this.get(`Content-Type`)||this.type(`html`);break;case`boolean`:case`number`:case`object`:if(t===null)t=``;else if(ArrayBuffer.isView(t))this.get(`Content-Type`)||this.type(`bin`);else return this.json(t);break}typeof t==`string`&&(n=`utf8`,i=this.get(`Content-Type`),typeof i==`string`&&this.set(`Content-Type`,v(i,`utf-8`)));var o=a.get(`etag fn`),s=!this.get(`ETag`)&&typeof o==`function`,c;t!==void 0&&(D.isBuffer(t)?c=t.length:!s&&t.length<1e3?c=D.byteLength(t,n):(t=D.from(t,n),n=void 0,c=t.length),this.set(`Content-Length`,c));var l;return s&&c!==void 0&&(l=o(t,n))&&this.set(`ETag`,l),r.fresh&&this.status(304),(this.statusCode===204||this.statusCode===304)&&(this.removeHeader(`Content-Type`),this.removeHeader(`Content-Length`),this.removeHeader(`Transfer-Encoding`),t=``),this.statusCode===205&&(this.set(`Content-Length`,`0`),this.removeHeader(`Transfer-Encoding`),t=``),r.method===`HEAD`?this.end():this.end(t,n),this},O.json=function json(e){var t=this.app,n=t.get(`json escape`),r=stringify(e,t.get(`json replacer`),t.get(`json spaces`),n);return this.get(`Content-Type`)||this.set(`Content-Type`,`application/json`),this.send(r)},O.jsonp=function jsonp(e){var t=this.app,n=t.get(`json escape`),r=stringify(e,t.get(`json replacer`),t.get(`json spaces`),n),i=this.req.query[t.get(`jsonp callback name`)];return this.get(`Content-Type`)||(this.set(`X-Content-Type-Options`,`nosniff`),this.set(`Content-Type`,`application/json`)),Array.isArray(i)&&(i=i[0]),typeof i==`string`&&i.length!==0&&(this.set(`X-Content-Type-Options`,`nosniff`),this.set(`Content-Type`,`text/javascript`),i=i.replace(/[^\[\]\w$.]/g,``),r===void 0?r=``:typeof r==`string`&&(r=r.replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)),r=`/**/ typeof `+i+` === 'function' && `+i+`(`+r+`);`),this.send(r)},O.sendStatus=function sendStatus(e){var t=m.message[e]||String(e);return this.status(e),this.type(`txt`),this.send(t)},O.sendFile=function sendFile(e,t,n){var r=n,i=this.req,a=this,o=i.next,s=t||{};if(!e)throw TypeError(`path argument is required to res.sendFile`);if(typeof e!=`string`)throw TypeError(`path must be a string to res.sendFile`);if(typeof t==`function`&&(r=t,s={}),!s.root&&!p(e))throw TypeError(`path must be absolute or specify root to res.sendFile`);var c=encodeURI(e);s.etag=this.app.enabled(`etag`),sendfile(a,b(i,c,s),s,function(e){if(r)return r(e);if(e&&e.code===`EISDIR`)return o();e&&e.code!==`ECONNABORTED`&&e.syscall!==`write`&&o(e)})},O.download=function download(e,t,r,i){var a=i,o=t,s=r||null;typeof t==`function`?(a=t,o=null,s=null):typeof r==`function`&&(a=r,s=null),typeof t==`object`&&(typeof r==`function`||r===void 0)&&(o=null,s=t);var c={"Content-Disposition":n(o||e)};if(s&&s.headers)for(var l=Object.keys(s.headers),u=0;u<l.length;u++){var d=l[u];d.toLowerCase()!==`content-disposition`&&(c[d]=s.headers[d])}s=Object.create(s),s.headers=c;var p=s.root?e:w(e);return this.sendFile(p,s,a)},O.contentType=O.type=function contentType(e){var t=e.indexOf(`/`)===-1?l.contentType(e)||`application/octet-stream`:e;return this.set(`Content-Type`,t)},O.format=function(e){var t=this.req,n=t.next,i=Object.keys(e).filter(function(e){return e!==`default`}),a=i.length>0?t.accepts(i):!1;return this.vary(`Accept`),a?(this.set(`Content-Type`,g(a).value),e[a](t,this,n)):e.default?e.default(t,this,n):n(r(406,{types:_(i).map(function(e){return e.value})})),this},O.attachment=function attachment(e){return e&&this.type(S(e)),this.set(`Content-Disposition`,n(e)),this},O.append=function append(e,t){var n=this.get(e),r=t;return n&&(r=Array.isArray(n)?n.concat(t):Array.isArray(t)?[n].concat(t):[n,t]),this.set(e,r)},O.set=O.header=function header(e,t){if(arguments.length===2){var n=Array.isArray(t)?t.map(String):String(t);if(e.toLowerCase()===`content-type`){if(Array.isArray(n))throw TypeError(`Content-Type cannot be set to an Array`);n=l.contentType(n)}this.setHeader(e,n)}else for(var r in e)this.set(r,e[r]);return this},O.get=function(e){return this.getHeader(e)},O.clearCookie=function clearCookie(e,t){let n={path:`/`,...t,expires:new Date(1)};return delete n.maxAge,this.cookie(e,``,n)},O.cookie=function(e,t,n){var r={...n},i=this.req.secret,a=r.signed;if(a&&!i)throw Error(`cookieParser("secret") required for signed cookies`);var o=typeof t==`object`?`j:`+JSON.stringify(t):String(t);if(a&&(o=`s:`+h(o,i)),r.maxAge!=null){var s=r.maxAge-0;isNaN(s)||(r.expires=new Date(Date.now()+s),r.maxAge=Math.floor(s/1e3))}return r.path??=`/`,this.append(`Set-Cookie`,y.serialize(e,String(o),r)),this},O.location=function location(e){return this.set(`Location`,a(e))},O.redirect=function redirect(e){var t=e,n,r=302;arguments.length===2&&(r=arguments[0],t=arguments[1]),t||i(`Provide a url argument`),typeof t!=`string`&&i(`Url must be a string`),typeof r!=`number`&&i(`Status must be a number`),t=this.location(t).get(`Location`),this.format({text:function(){n=m.message[r]+`. Redirecting to `+t},html:function(){var e=o(t);n=`<p>`+m.message[r]+`. Redirecting to `+e+`</p>`},default:function(){n=``}}),this.status(r),this.set(`Content-Length`,D.byteLength(n)),this.req.method===`HEAD`?this.end():this.end(n)},O.vary=function(e){return E(this,e),this},O.render=function render(e,t,n){var r=this.req.app,done=n,i=t||{},a=this.req,o=this;typeof t==`function`&&(done=t,i={}),i._locals=o.locals,done||=function(e,t){if(e)return a.next(e);o.send(t)},r.render(e,i,done)};function sendfile(e,t,n,r){var i=!1,a;function onaborted(){if(!i){i=!0;var e=Error(`Request aborted`);e.code=`ECONNABORTED`,r(e)}}function ondirectory(){if(!i){i=!0;var e=Error(`EISDIR, read`);e.code=`EISDIR`,r(e)}}function onerror(e){i||(i=!0,r(e))}function onend(){i||(i=!0,r())}function onfile(){a=!1}function onfinish(e){if(e&&e.code===`ECONNRESET`)return onaborted();if(e)return onerror(e);i||setImmediate(function(){if(a!==!1&&!i){onaborted();return}i||(i=!0,r())})}function onstream(){a=!0}t.on(`directory`,ondirectory),t.on(`end`,onend),t.on(`error`,onerror),t.on(`file`,onfile),t.on(`stream`,onstream),c(e,onfinish),n.headers&&t.on(`headers`,function headers(e){for(var t=n.headers,r=Object.keys(t),i=0;i<r.length;i++){var a=r[i];e.setHeader(a,t[a])}}),t.pipe(e)}function stringify(e,t,n,r){var i=t||n?JSON.stringify(e,t,n):JSON.stringify(e);return r&&typeof i==`string`&&(i=i.replace(/[<>&]/g,function(e){switch(e.charCodeAt(0)){case 60:return`\\u003c`;case 62:return`\\u003e`;case 38:return`\\u0026`;default:return e}})),i}})),Yt=__commonJSMin(((e,t)=>{
329
+ var n=Ut(),r=k(),i=x()(`express`),a=_t(),o=vt(),s=u(`node:http`),c=le(),l=J(),d=u(`node:path`),p=u(`node:path`).isAbsolute,m=T(),h=Wt().sign,g=Q().normalizeType,_=Q().normalizeTypes,v=Q().setCharset,y=Gt(),b=Kt(),S=d.extname,w=d.resolve,E=qt();let{Buffer:D}=u(`node:buffer`);var O=Object.create(s.ServerResponse.prototype);t.exports=O,O.status=function status(e){if(!Number.isInteger(e))throw TypeError(`Invalid status code: ${JSON.stringify(e)}. Status code must be an integer.`);if(e<100||e>999)throw RangeError(`Invalid status code: ${JSON.stringify(e)}. Status code must be greater than 99 and less than 1000.`);return this.statusCode=e,this},O.links=function(e){var t=this.get(`Link`)||``;return t&&(t+=`, `),this.set(`Link`,t+Object.keys(e).map(function(t){return Array.isArray(e[t])?e[t].map(function(e){return`<${e}>; rel="${t}"`}).join(`, `):`<${e[t]}>; rel="${t}"`}).join(`, `))},O.send=function send(e){var t=e,n,r=this.req,i,a=this.app;switch(typeof t){case`string`:this.get(`Content-Type`)||this.type(`html`);break;case`boolean`:case`number`:case`object`:if(t===null)t=``;else if(ArrayBuffer.isView(t))this.get(`Content-Type`)||this.type(`bin`);else return this.json(t);break}typeof t==`string`&&(n=`utf8`,i=this.get(`Content-Type`),typeof i==`string`&&this.set(`Content-Type`,v(i,`utf-8`)));var o=a.get(`etag fn`),s=!this.get(`ETag`)&&typeof o==`function`,c;t!==void 0&&(D.isBuffer(t)?c=t.length:!s&&t.length<1e3?c=D.byteLength(t,n):(t=D.from(t,n),n=void 0,c=t.length),this.set(`Content-Length`,c));var l;return s&&c!==void 0&&(l=o(t,n))&&this.set(`ETag`,l),r.fresh&&this.status(304),(this.statusCode===204||this.statusCode===304)&&(this.removeHeader(`Content-Type`),this.removeHeader(`Content-Length`),this.removeHeader(`Transfer-Encoding`),t=``),this.statusCode===205&&(this.set(`Content-Length`,`0`),this.removeHeader(`Transfer-Encoding`),t=``),r.method===`HEAD`?this.end():this.end(t,n),this},O.json=function json(e){var t=this.app,n=t.get(`json escape`),r=stringify(e,t.get(`json replacer`),t.get(`json spaces`),n);return this.get(`Content-Type`)||this.set(`Content-Type`,`application/json`),this.send(r)},O.jsonp=function jsonp(e){var t=this.app,n=t.get(`json escape`),r=stringify(e,t.get(`json replacer`),t.get(`json spaces`),n),i=this.req.query[t.get(`jsonp callback name`)];return this.get(`Content-Type`)||(this.set(`X-Content-Type-Options`,`nosniff`),this.set(`Content-Type`,`application/json`)),Array.isArray(i)&&(i=i[0]),typeof i==`string`&&i.length!==0&&(this.set(`X-Content-Type-Options`,`nosniff`),this.set(`Content-Type`,`text/javascript`),i=i.replace(/[^\[\]\w$.]/g,``),r===void 0?r=``:typeof r==`string`&&(r=r.replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)),r=`/**/ typeof `+i+` === 'function' && `+i+`(`+r+`);`),this.send(r)},O.sendStatus=function sendStatus(e){var t=m.message[e]||String(e);return this.status(e),this.type(`txt`),this.send(t)},O.sendFile=function sendFile(e,t,n){var r=n,i=this.req,a=this,o=i.next,s=t||{};if(!e)throw TypeError(`path argument is required to res.sendFile`);if(typeof e!=`string`)throw TypeError(`path must be a string to res.sendFile`);if(typeof t==`function`&&(r=t,s={}),!s.root&&!p(e))throw TypeError(`path must be absolute or specify root to res.sendFile`);var c=encodeURI(e);s.etag=this.app.enabled(`etag`),sendfile(a,b(i,c,s),s,function(e){if(r)return r(e);if(e&&e.code===`EISDIR`)return o();e&&e.code!==`ECONNABORTED`&&e.syscall!==`write`&&o(e)})},O.download=function download(e,t,r,i){var a=i,o=t,s=r||null;typeof t==`function`?(a=t,o=null,s=null):typeof r==`function`&&(a=r,s=null),typeof t==`object`&&(typeof r==`function`||r===void 0)&&(o=null,s=t);var c={"Content-Disposition":n(o||e)};if(s&&s.headers)for(var l=Object.keys(s.headers),u=0;u<l.length;u++){var d=l[u];d.toLowerCase()!==`content-disposition`&&(c[d]=s.headers[d])}s=Object.create(s),s.headers=c;var p=s.root?e:w(e);return this.sendFile(p,s,a)},O.contentType=O.type=function contentType(e){var t=e.indexOf(`/`)===-1?l.contentType(e)||`application/octet-stream`:e;return this.set(`Content-Type`,t)},O.format=function(e){var t=this.req,n=t.next,i=Object.keys(e).filter(function(e){return e!=="default"}),a=i.length>0?t.accepts(i):!1;return this.vary(`Accept`),a?(this.set(`Content-Type`,g(a).value),e[a](t,this,n)):e.default?e.default(t,this,n):n(r(406,{types:_(i).map(function(e){return e.value})})),this},O.attachment=function attachment(e){return e&&this.type(S(e)),this.set(`Content-Disposition`,n(e)),this},O.append=function append(e,t){var n=this.get(e),r=t;return n&&(r=Array.isArray(n)?n.concat(t):Array.isArray(t)?[n].concat(t):[n,t]),this.set(e,r)},O.set=O.header=function header(e,t){if(arguments.length===2){var n=Array.isArray(t)?t.map(String):String(t);if(e.toLowerCase()===`content-type`){if(Array.isArray(n))throw TypeError(`Content-Type cannot be set to an Array`);n=l.contentType(n)}this.setHeader(e,n)}else for(var r in e)this.set(r,e[r]);return this},O.get=function(e){return this.getHeader(e)},O.clearCookie=function clearCookie(e,t){let n={path:`/`,...t,expires:new Date(1)};return delete n.maxAge,this.cookie(e,``,n)},O.cookie=function(e,t,n){var r={...n},i=this.req.secret,a=r.signed;if(a&&!i)throw Error(`cookieParser("secret") required for signed cookies`);var o=typeof t==`object`?`j:`+JSON.stringify(t):String(t);if(a&&(o=`s:`+h(o,i)),r.maxAge!=null){var s=r.maxAge-0;isNaN(s)||(r.expires=new Date(Date.now()+s),r.maxAge=Math.floor(s/1e3))}return r.path??=`/`,this.append(`Set-Cookie`,y.serialize(e,String(o),r)),this},O.location=function location(e){return this.set(`Location`,a(e))},O.redirect=function redirect(e){var t=e,n,r=302;arguments.length===2&&(r=arguments[0],t=arguments[1]),t||i(`Provide a url argument`),typeof t!=`string`&&i(`Url must be a string`),typeof r!=`number`&&i(`Status must be a number`),t=this.location(t).get(`Location`),this.format({text:function(){n=m.message[r]+`. Redirecting to `+t},html:function(){var e=o(t);n=`<p>`+m.message[r]+`. Redirecting to `+e+`</p>`},default:function(){n=``}}),this.status(r),this.set(`Content-Length`,D.byteLength(n)),this.req.method===`HEAD`?this.end():this.end(n)},O.vary=function(e){return E(this,e),this},O.render=function render(e,t,n){var r=this.req.app,done=n,i=t||{},a=this.req,o=this;typeof t==`function`&&(done=t,i={}),i._locals=o.locals,done||=function(e,t){if(e)return a.next(e);o.send(t)},r.render(e,i,done)};function sendfile(e,t,n,r){var i=!1,a;function onaborted(){if(!i){i=!0;var e=Error(`Request aborted`);e.code=`ECONNABORTED`,r(e)}}function ondirectory(){if(!i){i=!0;var e=Error(`EISDIR, read`);e.code=`EISDIR`,r(e)}}function onerror(e){i||(i=!0,r(e))}function onend(){i||(i=!0,r())}function onfile(){a=!1}function onfinish(e){if(e&&e.code===`ECONNRESET`)return onaborted();if(e)return onerror(e);i||setImmediate(function(){if(a!==!1&&!i){onaborted();return}i||(i=!0,r())})}function onstream(){a=!0}t.on(`directory`,ondirectory),t.on(`end`,onend),t.on(`error`,onerror),t.on(`file`,onfile),t.on(`stream`,onstream),c(e,onfinish),n.headers&&t.on(`headers`,function headers(e){for(var t=n.headers,r=Object.keys(t),i=0;i<r.length;i++){var a=r[i];e.setHeader(a,t[a])}}),t.pipe(e)}function stringify(e,t,n,r){var i=t||n?JSON.stringify(e,t,n):JSON.stringify(e);return r&&typeof i==`string`&&(i=i.replace(/[<>&]/g,function(e){switch(e.charCodeAt(0)){case 60:return`\\u003c`;case 62:return`\\u003e`;case 38:return`\\u0026`;default:return e}})),i}})),Yt=__commonJSMin(((e,t)=>{
330
330
  /*!
331
331
  * serve-static
332
332
  * Copyright(c) 2010 Sencha Inc.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/example-node-express-webserver",
3
- "version": "0.4.29",
3
+ "version": "0.4.31",
4
4
  "description": "Express.js blog showcase with JSON API and static frontend — a real Node.js web app running on GJS",
5
5
  "main": "dist/index.gjs.js",
6
6
  "type": "module",
@@ -21,12 +21,12 @@
21
21
  "build:public": "mkdir -p dist/public && cp -r src/public/* dist/public/"
22
22
  },
23
23
  "dependencies": {
24
- "@gjsify/http-soup-bridge": "^0.4.29"
24
+ "@gjsify/http-soup-bridge": "^0.4.31"
25
25
  },
26
26
  "devDependencies": {
27
- "@gjsify/cli": "^0.4.29",
28
- "@gjsify/node-globals": "^0.4.29",
29
- "@gjsify/runtime": "^0.4.29",
27
+ "@gjsify/cli": "^0.4.31",
28
+ "@gjsify/node-globals": "^0.4.31",
29
+ "@gjsify/runtime": "^0.4.31",
30
30
  "@types/express": "^5.0.6",
31
31
  "@types/node": "^25.9.1",
32
32
  "express": "^5.2.1",