Web Dev Solutions

Catalin Mititiuc

From d729079cdf63a4382e3e3225295784124e0a4d5d Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Thu, 23 May 2024 12:06:01 -0700 Subject: WIP: intercept request in test --- server.cjs | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'server.cjs') diff --git a/server.cjs b/server.cjs index 47e4723..27d578a 100644 --- a/server.cjs +++ b/server.cjs @@ -1,4 +1,44 @@ const { createServer } = require('esbuild-server'); +// const { IncomingMessage } = require('node:http'); +// const { URL } = require('node:url'); +// const path = require('node:path'); + +// class Request extends IncomingMessage { +// constructor(socket) { +// super(socket); +// } + +// get url() { +// console.log('getter called', this._url); +// return this._url; +// } + +// set url(val) { +// console.log('setter called', val); +// this._url = val; +// } +// } + +// const propDesc = Object.getOwnPropertyDescriptor(URL.prototype, 'pathname'); + +// // console.log('propDesc before', propDesc); + +// Object.defineProperty(URL.prototype, 'pathname', { +// __proto__: null, +// get: function() { +// const pathname = propDesc.get.call(this); +// console.log('get pathname', path.normalize(path.join('public', pathname))); + +// return pathname; +// }, +// // set: function(val) { +// // console.log('set pathname', val); +// // propDesc.set.call(this, val); +// // // this._pathname = val; +// // }, +// }); + +// console.log('path', path.normalize(path.join('public', 'assets/css/damage_block.css'))) const server = createServer( { @@ -12,6 +52,7 @@ const server = createServer( } }, { + // http: { IncomingMessage: Request }, static: 'public', ...(process.env.NODE_ENV === 'test') && { port: 3005, @@ -24,7 +65,7 @@ const server = createServer( const buildStart = Date.now(); server .start() - .then(() => { + .then((d) => { console.log(`Build completed in ${Date.now() - buildStart}ms`); }) .catch(() => { -- cgit v1.2.3