codeforlife 2.14.8 → 2.14.10

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.
@@ -1,6 +1,7 @@
1
- "use strict";var u=Object.create;var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var w=(r,s,e,t)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of v(s))!k.call(r,a)&&a!==e&&c(r,a,{get:()=>s[a],enumerable:!(t=m(s,a))||t.enumerable});return r};var o=(r,s,e)=>(e=r!=null?u(C(r)):{},w(s||!r||!r.__esModule?c(e,"default",{value:r,enumerable:!0}):e,r));const y=require("memory-cache"),S=require("node:crypto"),f=require("express"),l=require("node:fs/promises"),I=require("node:http");class P{envIsProduction;templateHtml;hostname;mode;port;base;app;server;cache;healthCheckCacheKey;healthCheckCacheTimeout;healthCheckStatusCodes;devtoolsWorkspaceUUID;constructor({mode:s,port:e,base:t}={}){this.envIsProduction=process.env.NODE_ENV==="production",this.templateHtml="",this.hostname=this.envIsProduction?"0.0.0.0":"127.0.0.1",this.mode=s||process.env.MODE||"development",this.port=e||(process.env.PORT?Number(process.env.PORT):this.envIsProduction?8080:5173),this.base=t||process.env.BASE||"",this.app=f(),this.server=I.createServer(this.app),this.cache=new y.Cache,this.healthCheckCacheKey="health-check",this.healthCheckCacheTimeout=3e4,this.healthCheckStatusCodes={healthy:200,startingUp:503,shuttingDown:503,unhealthy:503,unknown:503},this.devtoolsWorkspaceUUID=S.randomUUID()}getHealthCheck(s){return{healthStatus:"healthy",additionalInfo:"All healthy."}}handleHealthCheck(s,e){let t=this.cache.get(this.healthCheckCacheKey);if(t===null){const a=this.getHealthCheck(s);a.healthStatus!=="healthy"&&console.warn(`health check: ${JSON.stringify(a)}`),t={appId:process.env.APP_ID||"REPLACE_ME",healthStatus:a.healthStatus,lastCheckedTimestamp:new Date().toISOString(),additionalInformation:a.additionalInfo,startupTimestamp:new Date().toISOString(),appVersion:process.env.APP_VERSION||"REPLACE_ME",details:a.details||[]},this.cache.put(this.healthCheckCacheKey,t,this.healthCheckCacheTimeout)}e.status(this.healthCheckStatusCodes[t.healthStatus]).json(t)}async handleServeHtml(s,e,{getRenderAndTemplate:t,onServeError:a}){try{const h=s.originalUrl.replace(this.base,""),[n,p]=await t(h),i=await n(h),d=p.replace("<!--app-head-->",i.head??"").replace("<!--app-html-->",i.html??"");e.status(200).set({"Content-Type":"text/html"}).send(d)}catch(h){if(h instanceof Error){console.error(h.stack);const n=a(h);e.status(500).end(n)}}}handleChromeDevTools(s,e){if(this.envIsProduction)e.status(404).json({});else{const t=process.env.LOCAL_WORKSPACE_PATH;let a,h;t?(a=200,h={workspace:{uuid:this.devtoolsWorkspaceUUID,root:t}}):(a=404,h={error:"Local workspace path not configured."}),e.status(a).json(h)}}async setUpProduction(){const s=(await import("compression")).default,e=(await import("sirv")).default;return this.templateHtml=await l.readFile("./dist/client/index.html","utf-8"),this.app.use(s()),this.app.use(this.base,e("./dist/client",{extensions:[]})),{getRenderAndTemplate:async()=>{const t=(await import("../../../../dist/server/entry-server.js")).render,a=this.templateHtml;return[t,a]},onServeError:()=>{}}}async setUpDevelopment(){const{createServer:s}=await import("vite"),e=await s({configFile:"/workspace/frontend/vite.config.ts",server:{middlewareMode:!0,hmr:{server:this.server}},appType:"custom",base:this.base,mode:this.mode});return this.app.use(e.middlewares),{getRenderAndTemplate:async t=>{const a=(await e.ssrLoadModule("/src/entry-server.tsx")).render;let h=await l.readFile("./index.html","utf-8");return h=await e.transformIndexHtml(t,h),[a,h]},onServeError:t=>(e.ssrFixStacktrace(t),t.stack)}}async run(){const s=this.envIsProduction?await this.setUpProduction():await this.setUpDevelopment();this.app.get("/health-check",(e,t)=>{this.handleHealthCheck(e,t)}),this.app.get("/.well-known/appspecific/com.chrome.devtools.json",(e,t)=>{this.handleChromeDevTools(e,t)}),this.app.get("*",async(e,t)=>{await this.handleServeHtml(e,t,s)}),this.server.listen(this.port,this.hostname,()=>{let e=`Server started.
1
+ "use strict";var u=Object.create;var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var k=(o,s,e,t)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of v(s))!f.call(o,a)&&a!==e&&l(o,a,{get:()=>s[a],enumerable:!(t=m(s,a))||t.enumerable});return o};var i=(o,s,e)=>(e=o!=null?u(C(o)):{},k(s||!o||!o.__esModule?l(e,"default",{value:o,enumerable:!0}):e,o));const w=require("memory-cache"),g=require("node:crypto"),y=require("express"),n=require("node:fs/promises"),S=require("node:http");class I{envIsProduction;templateHtml;hostname;configFile;mode;port;base;app;server;cache;healthCheckCacheKey;healthCheckCacheTimeout;healthCheckStatusCodes;devtoolsWorkspaceUUID;constructor({mode:s,port:e,base:t}={}){this.envIsProduction=process.env.NODE_ENV==="production",this.templateHtml="",this.hostname=this.envIsProduction?"0.0.0.0":"127.0.0.1",this.configFile="./vite.config.ts",this.mode=s||process.env.MODE||"development",this.port=e||(process.env.PORT?Number(process.env.PORT):this.envIsProduction?8080:5173),this.base=t||process.env.BASE||"",this.app=y(),this.server=S.createServer(this.app),this.cache=new w.Cache,this.healthCheckCacheKey="health-check",this.healthCheckCacheTimeout=3e4,this.healthCheckStatusCodes={healthy:200,startingUp:503,shuttingDown:503,unhealthy:503,unknown:503},this.devtoolsWorkspaceUUID=g.randomUUID()}getHealthCheck(s){return{healthStatus:"healthy",additionalInfo:"All healthy."}}handleHealthCheck(s,e){let t=this.cache.get(this.healthCheckCacheKey);if(t===null){const a=this.getHealthCheck(s);a.healthStatus!=="healthy"&&console.warn(`health check: ${JSON.stringify(a)}`),t={appId:process.env.APP_ID||"REPLACE_ME",healthStatus:a.healthStatus,lastCheckedTimestamp:new Date().toISOString(),additionalInformation:a.additionalInfo,startupTimestamp:new Date().toISOString(),appVersion:process.env.APP_VERSION||"REPLACE_ME",details:a.details||[]},this.cache.put(this.healthCheckCacheKey,t,this.healthCheckCacheTimeout)}e.status(this.healthCheckStatusCodes[t.healthStatus]).json(t)}async handleServeHtml(s,e,{getRenderAndTemplate:t,onServeError:a}){try{const h=s.originalUrl.replace(this.base,""),[r,p]=await t(h),c=await r(h),d=p.replace("<!--app-head-->",c.head??"").replace("<!--app-html-->",c.html??"");e.status(200).set({"Content-Type":"text/html"}).send(d)}catch(h){if(h instanceof Error){console.error(h.stack);const r=a(h);e.status(500).end(r)}}}handleChromeDevTools(s,e){if(this.envIsProduction)e.status(404).json({});else{const t=process.env.LOCAL_WORKSPACE_PATH;let a,h;t?(a=200,h={workspace:{uuid:this.devtoolsWorkspaceUUID,root:t}}):(a=404,h={error:"Local workspace path not configured."}),e.status(a).json(h)}}async setUpProduction(){const s=(await import("compression")).default,e=(await import("sirv")).default;return this.templateHtml=await n.readFile("./dist/client/index.html","utf-8"),this.app.use(s()),this.app.use(this.base,e("./dist/client",{extensions:[]})),{getRenderAndTemplate:async()=>{const t=(await import("../../../../dist/server/entry-server.js")).render,a=this.templateHtml;return[t,a]},onServeError:()=>{}}}async setUpDevelopment(){const{createServer:s}=await import("vite");try{await n.stat(this.configFile)}catch{this.configFile="/workspace/frontend/vite.config.ts"}const e=await s({configFile:this.configFile,server:{middlewareMode:!0,hmr:{server:this.server}},appType:"custom",base:this.base,mode:this.mode});return this.app.use(e.middlewares),{getRenderAndTemplate:async t=>{const a=(await e.ssrLoadModule("/src/entry-server.tsx")).render;let h=await n.readFile("./index.html","utf-8");return h=await e.transformIndexHtml(t,h),[a,h]},onServeError:t=>(e.ssrFixStacktrace(t),t.stack)}}async run(){const s=this.envIsProduction?await this.setUpProduction():await this.setUpDevelopment();this.app.get("/health-check",(e,t)=>{this.handleHealthCheck(e,t)}),this.app.get("/.well-known/appspecific/com.chrome.devtools.json",(e,t)=>{this.handleChromeDevTools(e,t)}),this.app.get("*",async(e,t)=>{await this.handleServeHtml(e,t,s)}),this.server.listen(this.port,this.hostname,()=>{let e=`Server started.
2
2
  url: http://${this.hostname}:${this.port}
3
3
  environment: ${process.env.NODE_ENV}
4
4
  `;this.envIsProduction||(e+=`mode: ${this.mode}
5
- `),console.log(e)})}}module.exports=P;
5
+ config file: ${this.configFile}
6
+ `),console.log(e)})}}module.exports=I;
6
7
  //# sourceMappingURL=server.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.cjs.js","sources":["../../src/server/server.ts"],"sourcesContent":["/**\n * © Ocado Group\n * Created on 13/12/2024 at 12:15:05(+00:00).\n *\n * A server for an app in a live environment.\n * Based off: https://github.com/bluwy/create-vite-extra/blob/master/template-ssr-react-ts/server.js\n */\n\nimport { Cache, type CacheClass } from \"memory-cache\"\nimport { type UUID, randomUUID } from \"node:crypto\"\nimport express, { type Express, type Request, type Response } from \"express\"\nimport fs from \"node:fs/promises\"\nimport http from \"node:http\"\n\ntype Mode = \"development\" | \"staging\" | \"production\"\ntype Options = Partial<{\n mode: Mode\n port: number\n base: string\n}>\n\ntype HealthStatus =\n | \"healthy\"\n | \"startingUp\"\n | \"shuttingDown\"\n | \"unhealthy\"\n | \"unknown\"\ntype HealthCheck = {\n healthStatus: HealthStatus\n additionalInfo: string\n details?: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\ntype HealthCheckResponse = {\n appId: string\n healthStatus: HealthStatus\n lastCheckedTimestamp: string\n additionalInformation: string\n startupTimestamp: string\n appVersion: string\n details: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\n\ntype Render = (path: string) => Promise<{ head?: string; html?: string }>\ntype EntryModule = { render: Render }\ntype RenderAndTemplate = [Render, string]\ntype GetRenderAndTemplate = (path: string) => Promise<RenderAndTemplate>\ntype OnServeError = (error: Error) => string | undefined\n\ntype Setup = {\n getRenderAndTemplate: GetRenderAndTemplate\n onServeError: OnServeError\n}\n\nexport default class Server {\n envIsProduction: boolean\n templateHtml: string\n hostname: string\n mode: Mode\n port: number\n base: string\n app: Express\n server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>\n cache: CacheClass<string, any>\n healthCheckCacheKey: string\n healthCheckCacheTimeout: number\n healthCheckStatusCodes: Record<HealthStatus, number>\n devtoolsWorkspaceUUID: UUID\n\n constructor({ mode, port, base }: Options = {}) {\n this.envIsProduction = process.env.NODE_ENV === \"production\"\n this.templateHtml = \"\"\n this.hostname = this.envIsProduction ? \"0.0.0.0\" : \"127.0.0.1\"\n\n this.mode = mode || (process.env.MODE as Mode) || \"development\"\n this.port =\n port ||\n (process.env.PORT\n ? Number(process.env.PORT)\n : this.envIsProduction\n ? 8080\n : 5173)\n this.base = base || process.env.BASE || \"\"\n\n this.app = express()\n this.server = http.createServer(this.app)\n this.cache = new Cache()\n\n this.healthCheckCacheKey = \"health-check\"\n this.healthCheckCacheTimeout = 30000\n this.healthCheckStatusCodes = {\n // The app is running normally.\n healthy: 200,\n // The app is performing app-specific initialisation which must\n // complete before it will serve normal application requests\n // (perhaps the app is warming a cache or something similar). You\n // only need to use this status if your app will be in a start-up\n // mode for a prolonged period of time.\n startingUp: 503,\n // The app is shutting down. As with startingUp, you only need to\n // use this status if your app takes a prolonged amount of time\n // to shutdown, perhaps because it waits for a long-running\n // process to complete before shutting down.\n shuttingDown: 503,\n // The app is not running normally.\n unhealthy: 503,\n // The app is not able to report its own state.\n unknown: 503,\n }\n\n this.devtoolsWorkspaceUUID = randomUUID()\n }\n\n // @ts-expect-error unused var\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getHealthCheck(request: Request): HealthCheck {\n return {\n healthStatus: \"healthy\",\n additionalInfo: \"All healthy.\",\n }\n }\n\n handleHealthCheck(request: Request, response: Response): void {\n let value: HealthCheckResponse = this.cache.get(\n this.healthCheckCacheKey,\n ) as HealthCheckResponse\n if (value === null) {\n const healthCheck = this.getHealthCheck(request)\n\n if (healthCheck.healthStatus !== \"healthy\") {\n console.warn(`health check: ${JSON.stringify(healthCheck)}`)\n }\n\n value = {\n appId: process.env.APP_ID || \"REPLACE_ME\",\n healthStatus: healthCheck.healthStatus,\n lastCheckedTimestamp: new Date().toISOString(),\n additionalInformation: healthCheck.additionalInfo,\n startupTimestamp: new Date().toISOString(),\n appVersion: process.env.APP_VERSION || \"REPLACE_ME\",\n details: healthCheck.details || [],\n }\n\n this.cache.put(\n this.healthCheckCacheKey,\n value,\n this.healthCheckCacheTimeout,\n )\n }\n\n response.status(this.healthCheckStatusCodes[value.healthStatus]).json(value)\n }\n\n async handleServeHtml(\n request: Request,\n response: Response,\n { getRenderAndTemplate, onServeError }: Setup,\n ): Promise<void> {\n try {\n const path = request.originalUrl.replace(this.base, \"\")\n\n const [render, template] = await getRenderAndTemplate(path)\n\n const rendered = await render(path)\n\n const html = template\n .replace(`<!--app-head-->`, rendered.head ?? \"\")\n .replace(`<!--app-html-->`, rendered.html ?? \"\")\n\n response.status(200).set({ \"Content-Type\": \"text/html\" }).send(html)\n } catch (error) {\n if (error instanceof Error) {\n console.error(error.stack)\n const body = onServeError(error)\n response.status(500).end(body)\n }\n }\n }\n\n // @ts-expect-error unused var\n handleChromeDevTools(request: Request, response: Response) {\n if (this.envIsProduction) {\n response.status(404).json({})\n } else {\n const localWorkspacePath = process.env.LOCAL_WORKSPACE_PATH\n\n let code: number\n let body: object\n if (localWorkspacePath) {\n code = 200\n body = {\n workspace: {\n uuid: this.devtoolsWorkspaceUUID,\n root: localWorkspacePath,\n },\n }\n } else {\n code = 404\n body = { error: \"Local workspace path not configured.\" }\n }\n\n response.status(code).json(body)\n }\n }\n\n async setUpProduction(): Promise<Setup> {\n const compression = (await import(\"compression\")).default\n const sirv = (await import(\"sirv\")).default\n\n this.templateHtml = await fs.readFile(\"./dist/client/index.html\", \"utf-8\")\n\n this.app.use(compression())\n this.app.use(this.base, sirv(\"./dist/client\", { extensions: [] }))\n\n return {\n getRenderAndTemplate: async () => {\n const render = (\n (await import(\n // @ts-expect-error only present after building installing app.\n \"../../../../dist/server/entry-server.js\"\n )) as EntryModule\n ).render\n\n // Use cached template.\n const template = this.templateHtml\n\n return [render, template]\n },\n onServeError: () => undefined,\n }\n }\n\n async setUpDevelopment(): Promise<Setup> {\n const { createServer } = await import(\"vite\")\n\n const vite = await createServer({\n configFile: \"/workspace/frontend/vite.config.ts\",\n server: {\n middlewareMode: true,\n hmr: { server: this.server },\n },\n appType: \"custom\",\n base: this.base,\n mode: this.mode,\n })\n\n this.app.use(vite.middlewares)\n\n return {\n getRenderAndTemplate: async path => {\n const render = (\n (await vite.ssrLoadModule(\"/src/entry-server.tsx\")) as EntryModule\n ).render\n\n // Always read fresh template.\n let template = await fs.readFile(\"./index.html\", \"utf-8\")\n template = await vite.transformIndexHtml(path, template)\n\n return [render, template]\n },\n onServeError: error => {\n vite.ssrFixStacktrace(error)\n return error.stack\n },\n }\n }\n\n async run() {\n const setup = this.envIsProduction\n ? await this.setUpProduction()\n : await this.setUpDevelopment()\n\n this.app.get(\"/health-check\", (request, response) => {\n this.handleHealthCheck(request, response)\n })\n\n this.app.get(\n \"/.well-known/appspecific/com.chrome.devtools.json\",\n (request, response) => {\n this.handleChromeDevTools(request, response)\n },\n )\n\n this.app.get(\"*\", async (request, response) => {\n await this.handleServeHtml(request, response, setup)\n })\n\n this.server.listen(this.port, this.hostname, () => {\n let startMessage =\n \"Server started.\\n\" +\n `url: http://${this.hostname}:${this.port}\\n` +\n `environment: ${process.env.NODE_ENV}\\n`\n\n if (!this.envIsProduction) startMessage += `mode: ${this.mode}\\n`\n\n console.log(startMessage)\n })\n }\n}\n"],"names":["Server","mode","port","base","express","http","Cache","randomUUID","request","response","value","healthCheck","getRenderAndTemplate","onServeError","path","render","template","rendered","html","error","body","localWorkspacePath","code","compression","sirv","fs","createServer","vite","setup","startMessage"],"mappings":"2lBA6DA,MAAqBA,CAAO,CAC1B,gBACA,aACA,SACA,KACA,KACA,KACA,IACA,OACA,MACA,oBACA,wBACA,uBACA,sBAEA,YAAY,CAAE,KAAAC,EAAM,KAAAC,EAAM,KAAAC,CAAA,EAAkB,CAA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QAAQ;AAAA,EAEjC,KAAK,kBAAiBA,GAAgB,SAAS,KAAK,IAAI;AAAA,GAE7D,QAAQ,IAAIA,CAAY,CAC1B,CAAC,CACH,CACF"}
1
+ {"version":3,"file":"server.cjs.js","sources":["../../src/server/server.ts"],"sourcesContent":["/**\n * © Ocado Group\n * Created on 13/12/2024 at 12:15:05(+00:00).\n *\n * A server for an app in a live environment.\n * Based off: https://github.com/bluwy/create-vite-extra/blob/master/template-ssr-react-ts/server.js\n */\n\nimport { Cache, type CacheClass } from \"memory-cache\"\nimport { type UUID, randomUUID } from \"node:crypto\"\nimport express, { type Express, type Request, type Response } from \"express\"\nimport fs from \"node:fs/promises\"\nimport http from \"node:http\"\n\ntype Mode = \"development\" | \"staging\" | \"production\"\ntype Options = Partial<{\n mode: Mode\n port: number\n base: string\n}>\n\ntype HealthStatus =\n | \"healthy\"\n | \"startingUp\"\n | \"shuttingDown\"\n | \"unhealthy\"\n | \"unknown\"\ntype HealthCheck = {\n healthStatus: HealthStatus\n additionalInfo: string\n details?: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\ntype HealthCheckResponse = {\n appId: string\n healthStatus: HealthStatus\n lastCheckedTimestamp: string\n additionalInformation: string\n startupTimestamp: string\n appVersion: string\n details: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\n\ntype Render = (path: string) => Promise<{ head?: string; html?: string }>\ntype EntryModule = { render: Render }\ntype RenderAndTemplate = [Render, string]\ntype GetRenderAndTemplate = (path: string) => Promise<RenderAndTemplate>\ntype OnServeError = (error: Error) => string | undefined\n\ntype Setup = {\n getRenderAndTemplate: GetRenderAndTemplate\n onServeError: OnServeError\n}\n\nexport default class Server {\n envIsProduction: boolean\n templateHtml: string\n hostname: string\n configFile: string\n mode: Mode\n port: number\n base: string\n app: Express\n server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>\n cache: CacheClass<string, any>\n healthCheckCacheKey: string\n healthCheckCacheTimeout: number\n healthCheckStatusCodes: Record<HealthStatus, number>\n devtoolsWorkspaceUUID: UUID\n\n constructor({ mode, port, base }: Options = {}) {\n this.envIsProduction = process.env.NODE_ENV === \"production\"\n this.templateHtml = \"\"\n this.hostname = this.envIsProduction ? \"0.0.0.0\" : \"127.0.0.1\"\n\n this.configFile = \"./vite.config.ts\"\n this.mode = mode || (process.env.MODE as Mode) || \"development\"\n this.port =\n port ||\n (process.env.PORT\n ? Number(process.env.PORT)\n : this.envIsProduction\n ? 8080\n : 5173)\n this.base = base || process.env.BASE || \"\"\n\n this.app = express()\n this.server = http.createServer(this.app)\n this.cache = new Cache()\n\n this.healthCheckCacheKey = \"health-check\"\n this.healthCheckCacheTimeout = 30000\n this.healthCheckStatusCodes = {\n // The app is running normally.\n healthy: 200,\n // The app is performing app-specific initialisation which must\n // complete before it will serve normal application requests\n // (perhaps the app is warming a cache or something similar). You\n // only need to use this status if your app will be in a start-up\n // mode for a prolonged period of time.\n startingUp: 503,\n // The app is shutting down. As with startingUp, you only need to\n // use this status if your app takes a prolonged amount of time\n // to shutdown, perhaps because it waits for a long-running\n // process to complete before shutting down.\n shuttingDown: 503,\n // The app is not running normally.\n unhealthy: 503,\n // The app is not able to report its own state.\n unknown: 503,\n }\n\n this.devtoolsWorkspaceUUID = randomUUID()\n }\n\n // @ts-expect-error unused var\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getHealthCheck(request: Request): HealthCheck {\n return {\n healthStatus: \"healthy\",\n additionalInfo: \"All healthy.\",\n }\n }\n\n handleHealthCheck(request: Request, response: Response): void {\n let value: HealthCheckResponse = this.cache.get(\n this.healthCheckCacheKey,\n ) as HealthCheckResponse\n if (value === null) {\n const healthCheck = this.getHealthCheck(request)\n\n if (healthCheck.healthStatus !== \"healthy\") {\n console.warn(`health check: ${JSON.stringify(healthCheck)}`)\n }\n\n value = {\n appId: process.env.APP_ID || \"REPLACE_ME\",\n healthStatus: healthCheck.healthStatus,\n lastCheckedTimestamp: new Date().toISOString(),\n additionalInformation: healthCheck.additionalInfo,\n startupTimestamp: new Date().toISOString(),\n appVersion: process.env.APP_VERSION || \"REPLACE_ME\",\n details: healthCheck.details || [],\n }\n\n this.cache.put(\n this.healthCheckCacheKey,\n value,\n this.healthCheckCacheTimeout,\n )\n }\n\n response.status(this.healthCheckStatusCodes[value.healthStatus]).json(value)\n }\n\n async handleServeHtml(\n request: Request,\n response: Response,\n { getRenderAndTemplate, onServeError }: Setup,\n ): Promise<void> {\n try {\n const path = request.originalUrl.replace(this.base, \"\")\n\n const [render, template] = await getRenderAndTemplate(path)\n\n const rendered = await render(path)\n\n const html = template\n .replace(`<!--app-head-->`, rendered.head ?? \"\")\n .replace(`<!--app-html-->`, rendered.html ?? \"\")\n\n response.status(200).set({ \"Content-Type\": \"text/html\" }).send(html)\n } catch (error) {\n if (error instanceof Error) {\n console.error(error.stack)\n const body = onServeError(error)\n response.status(500).end(body)\n }\n }\n }\n\n // @ts-expect-error unused var\n handleChromeDevTools(request: Request, response: Response) {\n if (this.envIsProduction) {\n response.status(404).json({})\n } else {\n const localWorkspacePath = process.env.LOCAL_WORKSPACE_PATH\n\n let code: number\n let body: object\n if (localWorkspacePath) {\n code = 200\n body = {\n workspace: {\n uuid: this.devtoolsWorkspaceUUID,\n root: localWorkspacePath,\n },\n }\n } else {\n code = 404\n body = { error: \"Local workspace path not configured.\" }\n }\n\n response.status(code).json(body)\n }\n }\n\n async setUpProduction(): Promise<Setup> {\n const compression = (await import(\"compression\")).default\n const sirv = (await import(\"sirv\")).default\n\n this.templateHtml = await fs.readFile(\"./dist/client/index.html\", \"utf-8\")\n\n this.app.use(compression())\n this.app.use(this.base, sirv(\"./dist/client\", { extensions: [] }))\n\n return {\n getRenderAndTemplate: async () => {\n const render = (\n (await import(\n // @ts-expect-error only present after building installing app.\n \"../../../../dist/server/entry-server.js\"\n )) as EntryModule\n ).render\n\n // Use cached template.\n const template = this.templateHtml\n\n return [render, template]\n },\n onServeError: () => undefined,\n }\n }\n\n async setUpDevelopment(): Promise<Setup> {\n const { createServer } = await import(\"vite\")\n\n // Check if service has its own config, else fall back to workspace config.\n try {\n await fs.stat(this.configFile)\n } catch {\n this.configFile = \"/workspace/frontend/vite.config.ts\"\n }\n\n const vite = await createServer({\n configFile: this.configFile,\n server: {\n middlewareMode: true,\n hmr: { server: this.server },\n },\n appType: \"custom\",\n base: this.base,\n mode: this.mode,\n })\n\n this.app.use(vite.middlewares)\n\n return {\n getRenderAndTemplate: async path => {\n const render = (\n (await vite.ssrLoadModule(\"/src/entry-server.tsx\")) as EntryModule\n ).render\n\n // Always read fresh template.\n let template = await fs.readFile(\"./index.html\", \"utf-8\")\n template = await vite.transformIndexHtml(path, template)\n\n return [render, template]\n },\n onServeError: error => {\n vite.ssrFixStacktrace(error)\n return error.stack\n },\n }\n }\n\n async run() {\n const setup = this.envIsProduction\n ? await this.setUpProduction()\n : await this.setUpDevelopment()\n\n this.app.get(\"/health-check\", (request, response) => {\n this.handleHealthCheck(request, response)\n })\n\n this.app.get(\n \"/.well-known/appspecific/com.chrome.devtools.json\",\n (request, response) => {\n this.handleChromeDevTools(request, response)\n },\n )\n\n this.app.get(\"*\", async (request, response) => {\n await this.handleServeHtml(request, response, setup)\n })\n\n this.server.listen(this.port, this.hostname, () => {\n let startMessage =\n \"Server started.\\n\" +\n `url: http://${this.hostname}:${this.port}\\n` +\n `environment: ${process.env.NODE_ENV}\\n`\n\n if (!this.envIsProduction) {\n startMessage +=\n `mode: ${this.mode}\\n` + `config file: ${this.configFile}\\n`\n }\n\n console.log(startMessage)\n })\n }\n}\n"],"names":["Server","mode","port","base","express","http","Cache","randomUUID","request","response","value","healthCheck","getRenderAndTemplate","onServeError","path","render","template","rendered","html","error","body","localWorkspacePath","code","compression","sirv","fs","createServer","vite","setup","startMessage"],"mappings":"2lBA6DA,MAAqBA,CAAO,CAC1B,gBACA,aACA,SACA,WACA,KACA,KACA,KACA,IACA,OACA,MACA,oBACA,wBACA,uBACA,sBAEA,YAAY,CAAE,KAAAC,EAAM,KAAAC,EAAM,KA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AED,KAAK,OAAO,OAAO,KAAK,KAAM,KAAK,SAAU,IAAM,CACjD,IAAIC,EACF;AAAA,cACe,KAAK,QAAQ,IAAI,KAAK,IAAI;AAAA,eACzB,QAAQ,IAAI,QAAQ;AAAA,EAEjC,KAAK,kBACRA,GACE,SAAS,KAAK,IAAI;AAAA,eAAuB,KAAK,UAAU;AAAA,GAG5D,QAAQ,IAAIA,CAAY,CAC1B,CAAC,CACH,CACF"}
@@ -3,10 +3,11 @@ import { randomUUID as p } from "node:crypto";
3
3
  import d from "express";
4
4
  import i from "node:fs/promises";
5
5
  import m from "node:http";
6
- class S {
6
+ class g {
7
7
  envIsProduction;
8
8
  templateHtml;
9
9
  hostname;
10
+ configFile;
10
11
  mode;
11
12
  port;
12
13
  base;
@@ -17,8 +18,8 @@ class S {
17
18
  healthCheckCacheTimeout;
18
19
  healthCheckStatusCodes;
19
20
  devtoolsWorkspaceUUID;
20
- constructor({ mode: h, port: e, base: t } = {}) {
21
- this.envIsProduction = process.env.NODE_ENV === "production", this.templateHtml = "", this.hostname = this.envIsProduction ? "0.0.0.0" : "127.0.0.1", this.mode = h || process.env.MODE || "development", this.port = e || (process.env.PORT ? Number(process.env.PORT) : this.envIsProduction ? 8080 : 5173), this.base = t || process.env.BASE || "", this.app = d(), this.server = m.createServer(this.app), this.cache = new l(), this.healthCheckCacheKey = "health-check", this.healthCheckCacheTimeout = 3e4, this.healthCheckStatusCodes = {
21
+ constructor({ mode: o, port: e, base: t } = {}) {
22
+ this.envIsProduction = process.env.NODE_ENV === "production", this.templateHtml = "", this.hostname = this.envIsProduction ? "0.0.0.0" : "127.0.0.1", this.configFile = "./vite.config.ts", this.mode = o || process.env.MODE || "development", this.port = e || (process.env.PORT ? Number(process.env.PORT) : this.envIsProduction ? 8080 : 5173), this.base = t || process.env.BASE || "", this.app = d(), this.server = m.createServer(this.app), this.cache = new l(), this.healthCheckCacheKey = "health-check", this.healthCheckCacheTimeout = 3e4, this.healthCheckStatusCodes = {
22
23
  // The app is running normally.
23
24
  healthy: 200,
24
25
  // The app is performing app-specific initialisation which must
@@ -40,18 +41,18 @@ class S {
40
41
  }
41
42
  // @ts-expect-error unused var
42
43
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
43
- getHealthCheck(h) {
44
+ getHealthCheck(o) {
44
45
  return {
45
46
  healthStatus: "healthy",
46
47
  additionalInfo: "All healthy."
47
48
  };
48
49
  }
49
- handleHealthCheck(h, e) {
50
+ handleHealthCheck(o, e) {
50
51
  let t = this.cache.get(
51
52
  this.healthCheckCacheKey
52
53
  );
53
54
  if (t === null) {
54
- const s = this.getHealthCheck(h);
55
+ const s = this.getHealthCheck(o);
55
56
  s.healthStatus !== "healthy" && console.warn(`health check: ${JSON.stringify(s)}`), t = {
56
57
  appId: process.env.APP_ID || "REPLACE_ME",
57
58
  healthStatus: s.healthStatus,
@@ -68,20 +69,20 @@ class S {
68
69
  }
69
70
  e.status(this.healthCheckStatusCodes[t.healthStatus]).json(t);
70
71
  }
71
- async handleServeHtml(h, e, { getRenderAndTemplate: t, onServeError: s }) {
72
+ async handleServeHtml(o, e, { getRenderAndTemplate: t, onServeError: s }) {
72
73
  try {
73
- const a = h.originalUrl.replace(this.base, ""), [o, n] = await t(a), r = await o(a), c = n.replace("<!--app-head-->", r.head ?? "").replace("<!--app-html-->", r.html ?? "");
74
+ const a = o.originalUrl.replace(this.base, ""), [h, n] = await t(a), r = await h(a), c = n.replace("<!--app-head-->", r.head ?? "").replace("<!--app-html-->", r.html ?? "");
74
75
  e.status(200).set({ "Content-Type": "text/html" }).send(c);
75
76
  } catch (a) {
76
77
  if (a instanceof Error) {
77
78
  console.error(a.stack);
78
- const o = s(a);
79
- e.status(500).end(o);
79
+ const h = s(a);
80
+ e.status(500).end(h);
80
81
  }
81
82
  }
82
83
  }
83
84
  // @ts-expect-error unused var
84
- handleChromeDevTools(h, e) {
85
+ handleChromeDevTools(o, e) {
85
86
  if (this.envIsProduction)
86
87
  e.status(404).json({});
87
88
  else {
@@ -96,8 +97,8 @@ class S {
96
97
  }
97
98
  }
98
99
  async setUpProduction() {
99
- const h = (await import("compression")).default, e = (await import("sirv")).default;
100
- return this.templateHtml = await i.readFile("./dist/client/index.html", "utf-8"), this.app.use(h()), this.app.use(this.base, e("./dist/client", { extensions: [] })), {
100
+ const o = (await import("compression")).default, e = (await import("sirv")).default;
101
+ return this.templateHtml = await i.readFile("./dist/client/index.html", "utf-8"), this.app.use(o()), this.app.use(this.base, e("./dist/client", { extensions: [] })), {
101
102
  getRenderAndTemplate: async () => {
102
103
  const t = (await import(
103
104
  // @ts-expect-error only present after building installing app.
@@ -110,8 +111,14 @@ class S {
110
111
  };
111
112
  }
112
113
  async setUpDevelopment() {
113
- const { createServer: h } = await import("vite"), e = await h({
114
- configFile: "/workspace/frontend/vite.config.ts",
114
+ const { createServer: o } = await import("vite");
115
+ try {
116
+ await i.stat(this.configFile);
117
+ } catch {
118
+ this.configFile = "/workspace/frontend/vite.config.ts";
119
+ }
120
+ const e = await o({
121
+ configFile: this.configFile,
115
122
  server: {
116
123
  middlewareMode: !0,
117
124
  hmr: { server: this.server }
@@ -130,7 +137,7 @@ class S {
130
137
  };
131
138
  }
132
139
  async run() {
133
- const h = this.envIsProduction ? await this.setUpProduction() : await this.setUpDevelopment();
140
+ const o = this.envIsProduction ? await this.setUpProduction() : await this.setUpDevelopment();
134
141
  this.app.get("/health-check", (e, t) => {
135
142
  this.handleHealthCheck(e, t);
136
143
  }), this.app.get(
@@ -139,18 +146,19 @@ class S {
139
146
  this.handleChromeDevTools(e, t);
140
147
  }
141
148
  ), this.app.get("*", async (e, t) => {
142
- await this.handleServeHtml(e, t, h);
149
+ await this.handleServeHtml(e, t, o);
143
150
  }), this.server.listen(this.port, this.hostname, () => {
144
151
  let e = `Server started.
145
152
  url: http://${this.hostname}:${this.port}
146
153
  environment: ${process.env.NODE_ENV}
147
154
  `;
148
155
  this.envIsProduction || (e += `mode: ${this.mode}
156
+ config file: ${this.configFile}
149
157
  `), console.log(e);
150
158
  });
151
159
  }
152
160
  }
153
161
  export {
154
- S as default
162
+ g as default
155
163
  };
156
164
  //# sourceMappingURL=server.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.es.js","sources":["../../src/server/server.ts"],"sourcesContent":["/**\n * © Ocado Group\n * Created on 13/12/2024 at 12:15:05(+00:00).\n *\n * A server for an app in a live environment.\n * Based off: https://github.com/bluwy/create-vite-extra/blob/master/template-ssr-react-ts/server.js\n */\n\nimport { Cache, type CacheClass } from \"memory-cache\"\nimport { type UUID, randomUUID } from \"node:crypto\"\nimport express, { type Express, type Request, type Response } from \"express\"\nimport fs from \"node:fs/promises\"\nimport http from \"node:http\"\n\ntype Mode = \"development\" | \"staging\" | \"production\"\ntype Options = Partial<{\n mode: Mode\n port: number\n base: string\n}>\n\ntype HealthStatus =\n | \"healthy\"\n | \"startingUp\"\n | \"shuttingDown\"\n | \"unhealthy\"\n | \"unknown\"\ntype HealthCheck = {\n healthStatus: HealthStatus\n additionalInfo: string\n details?: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\ntype HealthCheckResponse = {\n appId: string\n healthStatus: HealthStatus\n lastCheckedTimestamp: string\n additionalInformation: string\n startupTimestamp: string\n appVersion: string\n details: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\n\ntype Render = (path: string) => Promise<{ head?: string; html?: string }>\ntype EntryModule = { render: Render }\ntype RenderAndTemplate = [Render, string]\ntype GetRenderAndTemplate = (path: string) => Promise<RenderAndTemplate>\ntype OnServeError = (error: Error) => string | undefined\n\ntype Setup = {\n getRenderAndTemplate: GetRenderAndTemplate\n onServeError: OnServeError\n}\n\nexport default class Server {\n envIsProduction: boolean\n templateHtml: string\n hostname: string\n mode: Mode\n port: number\n base: string\n app: Express\n server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>\n cache: CacheClass<string, any>\n healthCheckCacheKey: string\n healthCheckCacheTimeout: number\n healthCheckStatusCodes: Record<HealthStatus, number>\n devtoolsWorkspaceUUID: UUID\n\n constructor({ mode, port, base }: Options = {}) {\n this.envIsProduction = process.env.NODE_ENV === \"production\"\n this.templateHtml = \"\"\n this.hostname = this.envIsProduction ? \"0.0.0.0\" : \"127.0.0.1\"\n\n this.mode = mode || (process.env.MODE as Mode) || \"development\"\n this.port =\n port ||\n (process.env.PORT\n ? Number(process.env.PORT)\n : this.envIsProduction\n ? 8080\n : 5173)\n this.base = base || process.env.BASE || \"\"\n\n this.app = express()\n this.server = http.createServer(this.app)\n this.cache = new Cache()\n\n this.healthCheckCacheKey = \"health-check\"\n this.healthCheckCacheTimeout = 30000\n this.healthCheckStatusCodes = {\n // The app is running normally.\n healthy: 200,\n // The app is performing app-specific initialisation which must\n // complete before it will serve normal application requests\n // (perhaps the app is warming a cache or something similar). You\n // only need to use this status if your app will be in a start-up\n // mode for a prolonged period of time.\n startingUp: 503,\n // The app is shutting down. As with startingUp, you only need to\n // use this status if your app takes a prolonged amount of time\n // to shutdown, perhaps because it waits for a long-running\n // process to complete before shutting down.\n shuttingDown: 503,\n // The app is not running normally.\n unhealthy: 503,\n // The app is not able to report its own state.\n unknown: 503,\n }\n\n this.devtoolsWorkspaceUUID = randomUUID()\n }\n\n // @ts-expect-error unused var\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getHealthCheck(request: Request): HealthCheck {\n return {\n healthStatus: \"healthy\",\n additionalInfo: \"All healthy.\",\n }\n }\n\n handleHealthCheck(request: Request, response: Response): void {\n let value: HealthCheckResponse = this.cache.get(\n this.healthCheckCacheKey,\n ) as HealthCheckResponse\n if (value === null) {\n const healthCheck = this.getHealthCheck(request)\n\n if (healthCheck.healthStatus !== \"healthy\") {\n console.warn(`health check: ${JSON.stringify(healthCheck)}`)\n }\n\n value = {\n appId: process.env.APP_ID || \"REPLACE_ME\",\n healthStatus: healthCheck.healthStatus,\n lastCheckedTimestamp: new Date().toISOString(),\n additionalInformation: healthCheck.additionalInfo,\n startupTimestamp: new Date().toISOString(),\n appVersion: process.env.APP_VERSION || \"REPLACE_ME\",\n details: healthCheck.details || [],\n }\n\n this.cache.put(\n this.healthCheckCacheKey,\n value,\n this.healthCheckCacheTimeout,\n )\n }\n\n response.status(this.healthCheckStatusCodes[value.healthStatus]).json(value)\n }\n\n async handleServeHtml(\n request: Request,\n response: Response,\n { getRenderAndTemplate, onServeError }: Setup,\n ): Promise<void> {\n try {\n const path = request.originalUrl.replace(this.base, \"\")\n\n const [render, template] = await getRenderAndTemplate(path)\n\n const rendered = await render(path)\n\n const html = template\n .replace(`<!--app-head-->`, rendered.head ?? \"\")\n .replace(`<!--app-html-->`, rendered.html ?? \"\")\n\n response.status(200).set({ \"Content-Type\": \"text/html\" }).send(html)\n } catch (error) {\n if (error instanceof Error) {\n console.error(error.stack)\n const body = onServeError(error)\n response.status(500).end(body)\n }\n }\n }\n\n // @ts-expect-error unused var\n handleChromeDevTools(request: Request, response: Response) {\n if (this.envIsProduction) {\n response.status(404).json({})\n } else {\n const localWorkspacePath = process.env.LOCAL_WORKSPACE_PATH\n\n let code: number\n let body: object\n if (localWorkspacePath) {\n code = 200\n body = {\n workspace: {\n uuid: this.devtoolsWorkspaceUUID,\n root: localWorkspacePath,\n },\n }\n } else {\n code = 404\n body = { error: \"Local workspace path not configured.\" }\n }\n\n response.status(code).json(body)\n }\n }\n\n async setUpProduction(): Promise<Setup> {\n const compression = (await import(\"compression\")).default\n const sirv = (await import(\"sirv\")).default\n\n this.templateHtml = await fs.readFile(\"./dist/client/index.html\", \"utf-8\")\n\n this.app.use(compression())\n this.app.use(this.base, sirv(\"./dist/client\", { extensions: [] }))\n\n return {\n getRenderAndTemplate: async () => {\n const render = (\n (await import(\n // @ts-expect-error only present after building installing app.\n \"../../../../dist/server/entry-server.js\"\n )) as EntryModule\n ).render\n\n // Use cached template.\n const template = this.templateHtml\n\n return [render, template]\n },\n onServeError: () => undefined,\n }\n }\n\n async setUpDevelopment(): Promise<Setup> {\n const { createServer } = await import(\"vite\")\n\n const vite = await createServer({\n configFile: \"/workspace/frontend/vite.config.ts\",\n server: {\n middlewareMode: true,\n hmr: { server: this.server },\n },\n appType: \"custom\",\n base: this.base,\n mode: this.mode,\n })\n\n this.app.use(vite.middlewares)\n\n return {\n getRenderAndTemplate: async path => {\n const render = (\n (await vite.ssrLoadModule(\"/src/entry-server.tsx\")) as EntryModule\n ).render\n\n // Always read fresh template.\n let template = await fs.readFile(\"./index.html\", \"utf-8\")\n template = await vite.transformIndexHtml(path, template)\n\n return [render, template]\n },\n onServeError: error => {\n vite.ssrFixStacktrace(error)\n return error.stack\n },\n }\n }\n\n async run() {\n const setup = this.envIsProduction\n ? await this.setUpProduction()\n : await this.setUpDevelopment()\n\n this.app.get(\"/health-check\", (request, response) => {\n this.handleHealthCheck(request, response)\n })\n\n this.app.get(\n \"/.well-known/appspecific/com.chrome.devtools.json\",\n (request, response) => {\n this.handleChromeDevTools(request, response)\n },\n )\n\n this.app.get(\"*\", async (request, response) => {\n await this.handleServeHtml(request, response, setup)\n })\n\n this.server.listen(this.port, this.hostname, () => {\n let startMessage =\n \"Server started.\\n\" +\n `url: http://${this.hostname}:${this.port}\\n` +\n `environment: ${process.env.NODE_ENV}\\n`\n\n if (!this.envIsProduction) startMessage += `mode: ${this.mode}\\n`\n\n console.log(startMessage)\n })\n }\n}\n"],"names":["Server","mode","port","base","express","http","Cache","randomUUID","request","response","value","healthCheck","getRenderAndTemplate","onServeError","path","render","template","rendered","html","error","body","localWorkspacePath","code","compression","sirv","fs","createServer","vite","setup","startMessage"],"mappings":";;;;;AA6DA,MAAqBA,EAAO;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY,EAAE,MAAAC,GAAM,MAAAC,GAAM,MAAAC,EAAA,IAAkB,CAAA,GAAI;AAC9C,SAAK,kBAAkB,QAAQ,IAAI,aAAa,cAChD,KAAK,eA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K,kBACf,MAAM,KAAK,gBAAA,IACX,MAAM,KAAK,iBAAA;AAEf,SAAK,IAAI,IAAI,iBAAiB,CAACpB,GAASC,MAAa;AACnD,WAAK,kBAAkBD,GAASC,CAAQ;AAAA,IAC1C,CAAC,GAED,KAAK,IAAI;AAAA,MACP;AAAA,MACA,CAACD,GAASC,MAAa;AACrB,aAAK,qBAAqBD,GAASC,CAAQ;AAAA,MAC7C;AAAA,IAAA,GAGF,KAAK,IAAI,IAAI,KAAK,OAAOD,GAASC,MAAa;AAC7C,YAAM,KAAK,gBAAgBD,GAASC,GAAUmB,CAAK;AAAA,IACrD,CAAC,GAED,KAAK,OAAO,OAAO,KAAK,MAAM,KAAK,UAAU,MAAM;AACjD,UAAIC,IACF;AAAA,cACe,KAAK,QAAQ,IAAI,KAAK,IAAI;AAAA,eACzB,QAAQ,IAAI,QAAQ;AAAA;AAEtC,MAAK,KAAK,oBAAiBA,KAAgB,SAAS,KAAK,IAAI;AAAA,IAE7D,QAAQ,IAAIA,CAAY;AAAA,IAC1B,CAAC;AAAA,EACH;AACF;"}
1
+ {"version":3,"file":"server.es.js","sources":["../../src/server/server.ts"],"sourcesContent":["/**\n * © Ocado Group\n * Created on 13/12/2024 at 12:15:05(+00:00).\n *\n * A server for an app in a live environment.\n * Based off: https://github.com/bluwy/create-vite-extra/blob/master/template-ssr-react-ts/server.js\n */\n\nimport { Cache, type CacheClass } from \"memory-cache\"\nimport { type UUID, randomUUID } from \"node:crypto\"\nimport express, { type Express, type Request, type Response } from \"express\"\nimport fs from \"node:fs/promises\"\nimport http from \"node:http\"\n\ntype Mode = \"development\" | \"staging\" | \"production\"\ntype Options = Partial<{\n mode: Mode\n port: number\n base: string\n}>\n\ntype HealthStatus =\n | \"healthy\"\n | \"startingUp\"\n | \"shuttingDown\"\n | \"unhealthy\"\n | \"unknown\"\ntype HealthCheck = {\n healthStatus: HealthStatus\n additionalInfo: string\n details?: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\ntype HealthCheckResponse = {\n appId: string\n healthStatus: HealthStatus\n lastCheckedTimestamp: string\n additionalInformation: string\n startupTimestamp: string\n appVersion: string\n details: Array<{\n name: string\n description: string\n health: HealthStatus\n }>\n}\n\ntype Render = (path: string) => Promise<{ head?: string; html?: string }>\ntype EntryModule = { render: Render }\ntype RenderAndTemplate = [Render, string]\ntype GetRenderAndTemplate = (path: string) => Promise<RenderAndTemplate>\ntype OnServeError = (error: Error) => string | undefined\n\ntype Setup = {\n getRenderAndTemplate: GetRenderAndTemplate\n onServeError: OnServeError\n}\n\nexport default class Server {\n envIsProduction: boolean\n templateHtml: string\n hostname: string\n configFile: string\n mode: Mode\n port: number\n base: string\n app: Express\n server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>\n cache: CacheClass<string, any>\n healthCheckCacheKey: string\n healthCheckCacheTimeout: number\n healthCheckStatusCodes: Record<HealthStatus, number>\n devtoolsWorkspaceUUID: UUID\n\n constructor({ mode, port, base }: Options = {}) {\n this.envIsProduction = process.env.NODE_ENV === \"production\"\n this.templateHtml = \"\"\n this.hostname = this.envIsProduction ? \"0.0.0.0\" : \"127.0.0.1\"\n\n this.configFile = \"./vite.config.ts\"\n this.mode = mode || (process.env.MODE as Mode) || \"development\"\n this.port =\n port ||\n (process.env.PORT\n ? Number(process.env.PORT)\n : this.envIsProduction\n ? 8080\n : 5173)\n this.base = base || process.env.BASE || \"\"\n\n this.app = express()\n this.server = http.createServer(this.app)\n this.cache = new Cache()\n\n this.healthCheckCacheKey = \"health-check\"\n this.healthCheckCacheTimeout = 30000\n this.healthCheckStatusCodes = {\n // The app is running normally.\n healthy: 200,\n // The app is performing app-specific initialisation which must\n // complete before it will serve normal application requests\n // (perhaps the app is warming a cache or something similar). You\n // only need to use this status if your app will be in a start-up\n // mode for a prolonged period of time.\n startingUp: 503,\n // The app is shutting down. As with startingUp, you only need to\n // use this status if your app takes a prolonged amount of time\n // to shutdown, perhaps because it waits for a long-running\n // process to complete before shutting down.\n shuttingDown: 503,\n // The app is not running normally.\n unhealthy: 503,\n // The app is not able to report its own state.\n unknown: 503,\n }\n\n this.devtoolsWorkspaceUUID = randomUUID()\n }\n\n // @ts-expect-error unused var\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getHealthCheck(request: Request): HealthCheck {\n return {\n healthStatus: \"healthy\",\n additionalInfo: \"All healthy.\",\n }\n }\n\n handleHealthCheck(request: Request, response: Response): void {\n let value: HealthCheckResponse = this.cache.get(\n this.healthCheckCacheKey,\n ) as HealthCheckResponse\n if (value === null) {\n const healthCheck = this.getHealthCheck(request)\n\n if (healthCheck.healthStatus !== \"healthy\") {\n console.warn(`health check: ${JSON.stringify(healthCheck)}`)\n }\n\n value = {\n appId: process.env.APP_ID || \"REPLACE_ME\",\n healthStatus: healthCheck.healthStatus,\n lastCheckedTimestamp: new Date().toISOString(),\n additionalInformation: healthCheck.additionalInfo,\n startupTimestamp: new Date().toISOString(),\n appVersion: process.env.APP_VERSION || \"REPLACE_ME\",\n details: healthCheck.details || [],\n }\n\n this.cache.put(\n this.healthCheckCacheKey,\n value,\n this.healthCheckCacheTimeout,\n )\n }\n\n response.status(this.healthCheckStatusCodes[value.healthStatus]).json(value)\n }\n\n async handleServeHtml(\n request: Request,\n response: Response,\n { getRenderAndTemplate, onServeError }: Setup,\n ): Promise<void> {\n try {\n const path = request.originalUrl.replace(this.base, \"\")\n\n const [render, template] = await getRenderAndTemplate(path)\n\n const rendered = await render(path)\n\n const html = template\n .replace(`<!--app-head-->`, rendered.head ?? \"\")\n .replace(`<!--app-html-->`, rendered.html ?? \"\")\n\n response.status(200).set({ \"Content-Type\": \"text/html\" }).send(html)\n } catch (error) {\n if (error instanceof Error) {\n console.error(error.stack)\n const body = onServeError(error)\n response.status(500).end(body)\n }\n }\n }\n\n // @ts-expect-error unused var\n handleChromeDevTools(request: Request, response: Response) {\n if (this.envIsProduction) {\n response.status(404).json({})\n } else {\n const localWorkspacePath = process.env.LOCAL_WORKSPACE_PATH\n\n let code: number\n let body: object\n if (localWorkspacePath) {\n code = 200\n body = {\n workspace: {\n uuid: this.devtoolsWorkspaceUUID,\n root: localWorkspacePath,\n },\n }\n } else {\n code = 404\n body = { error: \"Local workspace path not configured.\" }\n }\n\n response.status(code).json(body)\n }\n }\n\n async setUpProduction(): Promise<Setup> {\n const compression = (await import(\"compression\")).default\n const sirv = (await import(\"sirv\")).default\n\n this.templateHtml = await fs.readFile(\"./dist/client/index.html\", \"utf-8\")\n\n this.app.use(compression())\n this.app.use(this.base, sirv(\"./dist/client\", { extensions: [] }))\n\n return {\n getRenderAndTemplate: async () => {\n const render = (\n (await import(\n // @ts-expect-error only present after building installing app.\n \"../../../../dist/server/entry-server.js\"\n )) as EntryModule\n ).render\n\n // Use cached template.\n const template = this.templateHtml\n\n return [render, template]\n },\n onServeError: () => undefined,\n }\n }\n\n async setUpDevelopment(): Promise<Setup> {\n const { createServer } = await import(\"vite\")\n\n // Check if service has its own config, else fall back to workspace config.\n try {\n await fs.stat(this.configFile)\n } catch {\n this.configFile = \"/workspace/frontend/vite.config.ts\"\n }\n\n const vite = await createServer({\n configFile: this.configFile,\n server: {\n middlewareMode: true,\n hmr: { server: this.server },\n },\n appType: \"custom\",\n base: this.base,\n mode: this.mode,\n })\n\n this.app.use(vite.middlewares)\n\n return {\n getRenderAndTemplate: async path => {\n const render = (\n (await vite.ssrLoadModule(\"/src/entry-server.tsx\")) as EntryModule\n ).render\n\n // Always read fresh template.\n let template = await fs.readFile(\"./index.html\", \"utf-8\")\n template = await vite.transformIndexHtml(path, template)\n\n return [render, template]\n },\n onServeError: error => {\n vite.ssrFixStacktrace(error)\n return error.stack\n },\n }\n }\n\n async run() {\n const setup = this.envIsProduction\n ? await this.setUpProduction()\n : await this.setUpDevelopment()\n\n this.app.get(\"/health-check\", (request, response) => {\n this.handleHealthCheck(request, response)\n })\n\n this.app.get(\n \"/.well-known/appspecific/com.chrome.devtools.json\",\n (request, response) => {\n this.handleChromeDevTools(request, response)\n },\n )\n\n this.app.get(\"*\", async (request, response) => {\n await this.handleServeHtml(request, response, setup)\n })\n\n this.server.listen(this.port, this.hostname, () => {\n let startMessage =\n \"Server started.\\n\" +\n `url: http://${this.hostname}:${this.port}\\n` +\n `environment: ${process.env.NODE_ENV}\\n`\n\n if (!this.envIsProduction) {\n startMessage +=\n `mode: ${this.mode}\\n` + `config file: ${this.configFile}\\n`\n }\n\n console.log(startMessage)\n })\n }\n}\n"],"names":["Server","mode","port","base","express","http","Cache","randomUUID","request","response","value","healthCheck","getRenderAndTemplate","onServeError","path","render","template","rendered","html","error","body","localWorkspacePath","code","compression","sirv","fs","createServer","vite","setup","startMessage"],"mappings":";;;;;AA6DA,MAAqBA,EAAO;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY,EAAE,MAAAC,GAAM,MAAAC,GAAM,MAAAC,EAAA,IAAkB,CAAA,GAAI;AAC9C,SAAK,kBAAkB,QAAQ,IAAI,aAAa,cAChD,KAAK,eAAe,IACpB,KAAK,WAAW,KAAK,kBAAkB,YAAY,aAEnD,KAAK,aAAa,oBAClB,KAAK,OAAOF,KAAS,QAAQ,IAAI,QAAiB,eAClD,KAAK,OACHC,MACC,QAAQ,IAAI,OACT,OAAO,QAAQ,IAAI,IAAI,IACvB,KAAK,kBACH,OACA,OACR,KAAK,OAAOC,KAAQ,QAAQ,IAAI,QAAQ,IAExC,KAAK,MAAMC,EAAA,GACX,KAAK,SAASC,EAAK,aAAa,KAAK,GAAG,GACxC,KAAK,QAAQ,IAAIC,EAAA,GAEjB,KAAK,sBAAsB,gBAC3B,KAAK,0BAA0B,KAC/B,KAAK,yBAAyB;AAAA;AAAA,MAE5B,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMT,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,MA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AAC,GAED,KAAK,OAAO,OAAO,KAAK,MAAM,KAAK,UAAU,MAAM;AACjD,UAAIC,IACF;AAAA,cACe,KAAK,QAAQ,IAAI,KAAK,IAAI;AAAA,eACzB,QAAQ,IAAI,QAAQ;AAAA;AAEtC,MAAK,KAAK,oBACRA,KACE,SAAS,KAAK,IAAI;AAAA,eAAuB,KAAK,UAAU;AAAA,IAG5D,QAAQ,IAAIA,CAAY;AAAA,IAC1B,CAAC;AAAA,EACH;AACF;"}
@@ -33,6 +33,7 @@ export default class Server {
33
33
  envIsProduction: boolean;
34
34
  templateHtml: string;
35
35
  hostname: string;
36
+ configFile: string;
36
37
  mode: Mode;
37
38
  port: number;
38
39
  base: string;
@@ -0,0 +1,7 @@
1
+ import { default as Cookies } from 'js-cookie';
2
+ /**
3
+ * A wrapper around js-cookie that supports Express-style JSON cookies. See:
4
+ * https://github.com/js-cookie/js-cookie/blob/main/SERVER_SIDE.md#express
5
+ */
6
+ declare const ExpressCookies: ReturnType<typeof Cookies.withConverter<any>>;
7
+ export default ExpressCookies;
@@ -1 +1 @@
1
- {"version":3,"file":"cookies.cjs.js","sources":["../../src/utils/cookies.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nimport Cookies from \"js-cookie\"\n\nconst EXPRESS_JSON_PREFIX = \"j:\"\n\n/**\n * A wrapper around js-cookie that supports Express-style JSON cookies. See:\n * https://github.com/js-cookie/js-cookie/blob/main/SERVER_SIDE.md#express\n */\nconst ExpressCookies = Cookies.withConverter<any>({\n write: (value, name) => {\n const stringValue =\n typeof value === \"object\" && value !== null\n ? EXPRESS_JSON_PREFIX + JSON.stringify(value as object)\n : String(value)\n\n return Cookies.converter.write(stringValue, name)\n },\n read: (cookieValue, name) => {\n const stringValue = Cookies.converter.read(cookieValue, name)\n\n return stringValue.startsWith(EXPRESS_JSON_PREFIX)\n ? (JSON.parse(stringValue.slice(EXPRESS_JSON_PREFIX.length)) as object)\n : stringValue\n },\n})\n\nexport default ExpressCookies\n"],"names":["EXPRESS_JSON_PREFIX","ExpressCookies","Cookies","value","name","stringValue","cookieValue"],"mappings":"0CAGMA,EAAsB,KAMtBC,EAAiBC,EAAQ,cAAmB,CAChD,MAAO,CAACC,EAAOC,IAAS,CACtB,MAAMC,EACJ,OAAOF,GAAU,UAAYA,IAAU,KACnCH,EAAsB,KAAK,UAAUG,CAAe,EACpD,OAAOA,CAAK,EAElB,OAAOD,EAAQ,UAAU,MAAMG,EAAaD,CAAI,CAClD,EACA,KAAM,CAACE,EAAaF,IAAS,CAC3B,MAAMC,EAAcH,EAAQ,UAAU,KAAKI,EAAaF,CAAI,EAE5D,OAAOC,EAAY,WAAWL,CAAmB,EAC5C,KAAK,MAAMK,EAAY,MAAML,EAAoB,MAAM,CAAC,EACzDK,CACN,CACF,CAAC"}
1
+ {"version":3,"file":"cookies.cjs.js","sources":["../../src/utils/cookies.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nimport Cookies from \"js-cookie\"\n\nconst EXPRESS_JSON_PREFIX = \"j:\"\n\n/**\n * A wrapper around js-cookie that supports Express-style JSON cookies. See:\n * https://github.com/js-cookie/js-cookie/blob/main/SERVER_SIDE.md#express\n */\nconst ExpressCookies: ReturnType<typeof Cookies.withConverter<any>> =\n Cookies.withConverter<any>({\n write: (value, name) => {\n const stringValue =\n typeof value === \"object\" && value !== null\n ? EXPRESS_JSON_PREFIX + JSON.stringify(value as object)\n : String(value)\n\n return Cookies.converter.write(stringValue, name)\n },\n read: (cookieValue, name) => {\n const stringValue = Cookies.converter.read(cookieValue, name)\n\n return stringValue.startsWith(EXPRESS_JSON_PREFIX)\n ? (JSON.parse(stringValue.slice(EXPRESS_JSON_PREFIX.length)) as object)\n : stringValue\n },\n })\n\nexport default ExpressCookies\n"],"names":["EXPRESS_JSON_PREFIX","ExpressCookies","Cookies","value","name","stringValue","cookieValue"],"mappings":"0CAGMA,EAAsB,KAMtBC,EACJC,EAAQ,cAAmB,CACzB,MAAO,CAACC,EAAOC,IAAS,CACtB,MAAMC,EACJ,OAAOF,GAAU,UAAYA,IAAU,KACnCH,EAAsB,KAAK,UAAUG,CAAe,EACpD,OAAOA,CAAK,EAElB,OAAOD,EAAQ,UAAU,MAAMG,EAAaD,CAAI,CAClD,EACA,KAAM,CAACE,EAAaF,IAAS,CAC3B,MAAMC,EAAcH,EAAQ,UAAU,KAAKI,EAAaF,CAAI,EAE5D,OAAOC,EAAY,WAAWL,CAAmB,EAC5C,KAAK,MAAMK,EAAY,MAAML,EAAoB,MAAM,CAAC,EACzDK,CACN,CACF,CAAC"}
@@ -1 +1,4 @@
1
1
  export {}
2
+ import Codeforlife from '../src/utils/cookies'
3
+ export default Codeforlife
4
+ export {}
@@ -1 +1 @@
1
- {"version":3,"file":"cookies.es.js","sources":["../../src/utils/cookies.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nimport Cookies from \"js-cookie\"\n\nconst EXPRESS_JSON_PREFIX = \"j:\"\n\n/**\n * A wrapper around js-cookie that supports Express-style JSON cookies. See:\n * https://github.com/js-cookie/js-cookie/blob/main/SERVER_SIDE.md#express\n */\nconst ExpressCookies = Cookies.withConverter<any>({\n write: (value, name) => {\n const stringValue =\n typeof value === \"object\" && value !== null\n ? EXPRESS_JSON_PREFIX + JSON.stringify(value as object)\n : String(value)\n\n return Cookies.converter.write(stringValue, name)\n },\n read: (cookieValue, name) => {\n const stringValue = Cookies.converter.read(cookieValue, name)\n\n return stringValue.startsWith(EXPRESS_JSON_PREFIX)\n ? (JSON.parse(stringValue.slice(EXPRESS_JSON_PREFIX.length)) as object)\n : stringValue\n },\n})\n\nexport default ExpressCookies\n"],"names":["EXPRESS_JSON_PREFIX","ExpressCookies","Cookies","value","name","stringValue","cookieValue"],"mappings":";AAGA,MAAMA,IAAsB,MAMtBC,IAAiBC,EAAQ,cAAmB;AAAA,EAChD,OAAO,CAACC,GAAOC,MAAS;AACtB,UAAMC,IACJ,OAAOF,KAAU,YAAYA,MAAU,OACnCH,IAAsB,KAAK,UAAUG,CAAe,IACpD,OAAOA,CAAK;AAElB,WAAOD,EAAQ,UAAU,MAAMG,GAAaD,CAAI;AAAA,EAClD;AAAA,EACA,MAAM,CAACE,GAAaF,MAAS;AAC3B,UAAMC,IAAcH,EAAQ,UAAU,KAAKI,GAAaF,CAAI;AAE5D,WAAOC,EAAY,WAAWL,CAAmB,IAC5C,KAAK,MAAMK,EAAY,MAAML,EAAoB,MAAM,CAAC,IACzDK;AAAA,EACN;AACF,CAAC;"}
1
+ {"version":3,"file":"cookies.es.js","sources":["../../src/utils/cookies.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nimport Cookies from \"js-cookie\"\n\nconst EXPRESS_JSON_PREFIX = \"j:\"\n\n/**\n * A wrapper around js-cookie that supports Express-style JSON cookies. See:\n * https://github.com/js-cookie/js-cookie/blob/main/SERVER_SIDE.md#express\n */\nconst ExpressCookies: ReturnType<typeof Cookies.withConverter<any>> =\n Cookies.withConverter<any>({\n write: (value, name) => {\n const stringValue =\n typeof value === \"object\" && value !== null\n ? EXPRESS_JSON_PREFIX + JSON.stringify(value as object)\n : String(value)\n\n return Cookies.converter.write(stringValue, name)\n },\n read: (cookieValue, name) => {\n const stringValue = Cookies.converter.read(cookieValue, name)\n\n return stringValue.startsWith(EXPRESS_JSON_PREFIX)\n ? (JSON.parse(stringValue.slice(EXPRESS_JSON_PREFIX.length)) as object)\n : stringValue\n },\n })\n\nexport default ExpressCookies\n"],"names":["EXPRESS_JSON_PREFIX","ExpressCookies","Cookies","value","name","stringValue","cookieValue"],"mappings":";AAGA,MAAMA,IAAsB,MAMtBC,IACJC,EAAQ,cAAmB;AAAA,EACzB,OAAO,CAACC,GAAOC,MAAS;AACtB,UAAMC,IACJ,OAAOF,KAAU,YAAYA,MAAU,OACnCH,IAAsB,KAAK,UAAUG,CAAe,IACpD,OAAOA,CAAK;AAElB,WAAOD,EAAQ,UAAU,MAAMG,GAAaD,CAAI;AAAA,EAClD;AAAA,EACA,MAAM,CAACE,GAAaF,MAAS;AAC3B,UAAMC,IAAcH,EAAQ,UAAU,KAAKI,GAAaF,CAAI;AAE5D,WAAOC,EAAY,WAAWL,CAAmB,IAC5C,KAAK,MAAMK,EAAY,MAAML,EAAoB,MAAM,CAAC,IACzDK;AAAA,EACN;AACF,CAAC;"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "codeforlife",
3
3
  "description": "Common frontend code",
4
4
  "private": false,
5
- "version": "2.14.8",
5
+ "version": "2.14.10",
6
6
  "type": "module",
7
7
  "types": "dist/index.d.ts",
8
8
  "module": "dist/index.es.js",
@@ -203,11 +203,11 @@
203
203
  "@reduxjs/toolkit": "2.9.0",
204
204
  "compression": "1.8.1",
205
205
  "dayjs": "1.11.19",
206
- "express": "4.22.1",
206
+ "express": "4.22.2",
207
207
  "formik": "2.4.9",
208
208
  "js-cookie": "3.0.5",
209
209
  "memory-cache": "0.2.0",
210
- "qs": "6.14.2",
210
+ "qs": "6.15.2",
211
211
  "react": "19.1.1",
212
212
  "react-dom": "19.1.1",
213
213
  "react-redux": "9.2.0",