@niledatabase/elysia 5.3.1-alpha.2 → 5.3.1-alpha.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/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var T=(t,e)=>{for(var o in e)p(t,o,{get:e[o],enumerable:!0})},b=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of m(e))!x.call(t,s)&&s!==o&&p(t,s,{get:()=>e[s],enumerable:!(n=g(e,s))||n.enumerable});return t};var q=t=>b(p({},"__esModule",{value:!0}),t);var C={};T(C,{elysia:()=>w});module.exports=q(C);var l=t=>t.replaceAll(/\{([^}]+)\}/g,":$1"),w=t=>{let e;return()=>({id:"elysia",onConfigure:o=>{e=o,typeof Bun<"u"&&(e.skipHostHeader=!0);let n={get:e.paths.get.map(l),post:e.paths.post.map(l),put:e.paths.put.map(l),delete:e.paths.delete.map(l)},s=e.handlers;n.get.forEach(a=>t.get(a,s.GET)),n.post.forEach(a=>t.post(a,s.POST)),n.put.forEach(a=>t.put(a,s.PUT)),n.delete.forEach(a=>t.delete(a,s.DELETE))},onHandleRequest:async o=>{let{error:n,debug:s}=e?.logger?.("[elysia]")??{error:()=>null,debug:()=>null};if(!e){n("No Nile instance passed on initialization, was onConfigure called?");return}let a=o?.[0];if(a instanceof Request){s("No request arg found");return}let r=a;if(!r||typeof r!="object"||!r.request||!r.set){n("No Elysia context found, unable to handle request");return}let{request:u,params:f,set:h}=r,E=f?.tenantId,y={headers:new Headers(u.headers),tenantId:E},i=await e.withContext(y,async c=>{let d=u.method;return await c.handlers[d](u,{disableExtensions:["elysia"]})});return i instanceof Response&&(i.headers.forEach((c,d)=>{h.headers[d]=c}),h.status=i.status),i}})};0&&(module.exports={elysia});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Elysia, Context as ElysiaContext } from \"elysia\";\nimport type { Server, Extension } from \"@niledatabase/server\";\n\nconst cleaner = (val: string) => val.replaceAll(/\\{([^}]+)\\}/g, \":$1\");\n\nexport const elysia = (app: Elysia): Extension => {\n let instance: Server;\n\n return () => ({\n id: \"elysia\",\n onConfigure: (server: Server) => {\n instance = server;\n\n const paths = {\n get: instance.paths.get.map(cleaner),\n post: instance.paths.post.map(cleaner),\n put: instance.paths.put.map(cleaner),\n delete: instance.paths.delete.map(cleaner),\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handlers = instance.handlers as any;\n\n paths.get.forEach((path) => app.get(path, handlers.GET));\n paths.post.forEach((path) => app.post(path, handlers.POST));\n paths.put.forEach((path) => app.put(path, handlers.PUT));\n paths.delete.forEach((path) => app.delete(path, handlers.DELETE));\n },\n\n onHandleRequest: async (params?: unknown[]) => {\n if (!instance) return;\n const arg = params?.[0];\n\n // If it's a raw Request, we let Nile handle it natively (or another extension)\n if (arg instanceof Request) {\n return;\n }\n\n // Check if it looks like an Elysia context\n // Elysia context has 'request', 'store', 'set', etc.\n // We do a loose check\n const ctx = arg as ElysiaContext;\n if (!ctx || typeof ctx !== \"object\" || !ctx.request || !ctx.set) {\n return;\n }\n\n const { request, params: pathParams, set } = ctx;\n const tenantId = pathParams?.tenantId;\n const headers = new Headers(request.headers);\n\n const context = {\n headers,\n tenantId,\n };\n\n const response = await instance.withContext(context, async (nileCtx) => {\n const method = request.method as \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n\n return (await nileCtx.handlers[method](request, {\n disableExtensions: [\"elysia\"],\n })) as Response;\n });\n\n if (response instanceof Response) {\n response.headers.forEach((value, key) => {\n set.headers[key] = value;\n });\n set.status = response.status;\n return response;\n }\n return response;\n },\n });\n};\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAMI,EAAWC,GAAgBA,EAAI,WAAW,eAAgB,KAAK,EAExDH,EAAUI,GAA2B,CAChD,IAAIC,EAEJ,MAAO,KAAO,CACZ,GAAI,SACJ,YAAcC,GAAmB,CAC/BD,EAAWC,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Elysia, Context as ElysiaContext } from \"elysia\";\nimport type { Server, Extension } from \"@niledatabase/server\";\n\nconst cleaner = (val: string) => val.replaceAll(/\\{([^}]+)\\}/g, \":$1\");\n\nexport const elysia = (app: Elysia): Extension => {\n let instance: Server;\n\n return () => ({\n id: \"elysia\",\n onConfigure: (server: Server) => {\n instance = server;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (typeof Bun !== \"undefined\") {\n instance.skipHostHeader = true;\n }\n\n const paths = {\n get: instance.paths.get.map(cleaner),\n post: instance.paths.post.map(cleaner),\n put: instance.paths.put.map(cleaner),\n delete: instance.paths.delete.map(cleaner),\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handlers = instance.handlers as any;\n\n paths.get.forEach((path) => app.get(path, handlers.GET));\n paths.post.forEach((path) => app.post(path, handlers.POST));\n paths.put.forEach((path) => app.put(path, handlers.PUT));\n paths.delete.forEach((path) => app.delete(path, handlers.DELETE));\n },\n\n onHandleRequest: async (params?: unknown[]) => {\n const { error, debug } = instance?.logger?.(\"[elysia]\") ?? {\n error: () => null,\n debug: () => null,\n };\n\n if (!instance) {\n error(\n \"No Nile instance passed on initialization, was onConfigure called?\"\n );\n return;\n }\n\n const arg = params?.[0];\n\n // If it's a raw Request, we let Nile handle it natively (or another extension)\n if (arg instanceof Request) {\n debug(\"No request arg found\");\n return;\n }\n\n // Check if it looks like an Elysia context\n // Elysia context has 'request', 'store', 'set', etc.\n // We do a loose check\n const ctx = arg as ElysiaContext;\n if (!ctx || typeof ctx !== \"object\" || !ctx.request || !ctx.set) {\n error(\"No Elysia context found, unable to handle request\");\n return;\n }\n\n const { request, params: pathParams, set } = ctx;\n const tenantId = pathParams?.tenantId;\n const headers = new Headers(request.headers);\n\n const context = {\n headers,\n tenantId,\n };\n\n const response = await instance.withContext(context, async (nileCtx) => {\n const method = request.method as \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n\n return (await nileCtx.handlers[method](request, {\n disableExtensions: [\"elysia\"],\n })) as Response;\n });\n\n if (response instanceof Response) {\n response.headers.forEach((value, key) => {\n set.headers[key] = value;\n });\n set.status = response.status;\n return response;\n }\n return response;\n },\n });\n};\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAMI,EAAWC,GAAgBA,EAAI,WAAW,eAAgB,KAAK,EAExDH,EAAUI,GAA2B,CAChD,IAAIC,EAEJ,MAAO,KAAO,CACZ,GAAI,SACJ,YAAcC,GAAmB,CAC/BD,EAAWC,EAGP,OAAO,IAAQ,MACjBD,EAAS,eAAiB,IAG5B,IAAME,EAAQ,CACZ,IAAKF,EAAS,MAAM,IAAI,IAAIH,CAAO,EACnC,KAAMG,EAAS,MAAM,KAAK,IAAIH,CAAO,EACrC,IAAKG,EAAS,MAAM,IAAI,IAAIH,CAAO,EACnC,OAAQG,EAAS,MAAM,OAAO,IAAIH,CAAO,CAC3C,EAGMM,EAAWH,EAAS,SAE1BE,EAAM,IAAI,QAASE,GAASL,EAAI,IAAIK,EAAMD,EAAS,GAAG,CAAC,EACvDD,EAAM,KAAK,QAASE,GAASL,EAAI,KAAKK,EAAMD,EAAS,IAAI,CAAC,EAC1DD,EAAM,IAAI,QAASE,GAASL,EAAI,IAAIK,EAAMD,EAAS,GAAG,CAAC,EACvDD,EAAM,OAAO,QAASE,GAASL,EAAI,OAAOK,EAAMD,EAAS,MAAM,CAAC,CAClE,EAEA,gBAAiB,MAAOE,GAAuB,CAC7C,GAAM,CAAE,MAAAC,EAAO,MAAAC,CAAM,EAAIP,GAAU,SAAS,UAAU,GAAK,CACzD,MAAO,IAAM,KACb,MAAO,IAAM,IACf,EAEA,GAAI,CAACA,EAAU,CACbM,EACE,oEACF,EACA,MACF,CAEA,IAAME,EAAMH,IAAS,CAAC,EAGtB,GAAIG,aAAe,QAAS,CAC1BD,EAAM,sBAAsB,EAC5B,MACF,CAKA,IAAME,EAAMD,EACZ,GAAI,CAACC,GAAO,OAAOA,GAAQ,UAAY,CAACA,EAAI,SAAW,CAACA,EAAI,IAAK,CAC/DH,EAAM,mDAAmD,EACzD,MACF,CAEA,GAAM,CAAE,QAAAI,EAAS,OAAQC,EAAY,IAAAC,CAAI,EAAIH,EACvCI,EAAWF,GAAY,SAGvBG,EAAU,CACd,QAHc,IAAI,QAAQJ,EAAQ,OAAO,EAIzC,SAAAG,CACF,EAEME,EAAW,MAAMf,EAAS,YAAYc,EAAS,MAAOE,GAAY,CACtE,IAAMC,EAASP,EAAQ,OAEvB,OAAQ,MAAMM,EAAQ,SAASC,CAAM,EAAEP,EAAS,CAC9C,kBAAmB,CAAC,QAAQ,CAC9B,CAAC,CACH,CAAC,EAED,OAAIK,aAAoB,WACtBA,EAAS,QAAQ,QAAQ,CAACG,EAAOC,IAAQ,CACvCP,EAAI,QAAQO,CAAG,EAAID,CACrB,CAAC,EACDN,EAAI,OAASG,EAAS,QACfA,CAGX,CACF,EACF","names":["index_exports","__export","elysia","__toCommonJS","cleaner","val","app","instance","server","paths","handlers","path","params","error","debug","arg","ctx","request","pathParams","set","tenantId","context","response","nileCtx","method","value","key"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var i=n=>n.replaceAll(/\{([^}]+)\}/g,":$1"),g=n=>{let e;return()=>({id:"elysia",onConfigure:l=>{e=l,typeof Bun<"u"&&(e.skipHostHeader=!0);let s={get:e.paths.get.map(i),post:e.paths.post.map(i),put:e.paths.put.map(i),delete:e.paths.delete.map(i)},a=e.handlers;s.get.forEach(t=>n.get(t,a.GET)),s.post.forEach(t=>n.post(t,a.POST)),s.put.forEach(t=>n.put(t,a.PUT)),s.delete.forEach(t=>n.delete(t,a.DELETE))},onHandleRequest:async l=>{let{error:s,debug:a}=e?.logger?.("[elysia]")??{error:()=>null,debug:()=>null};if(!e){s("No Nile instance passed on initialization, was onConfigure called?");return}let t=l?.[0];if(t instanceof Request){a("No request arg found");return}let o=t;if(!o||typeof o!="object"||!o.request||!o.set){s("No Elysia context found, unable to handle request");return}let{request:u,params:h,set:p}=o,f=h?.tenantId,E={headers:new Headers(u.headers),tenantId:f},r=await e.withContext(E,async c=>{let d=u.method;return await c.handlers[d](u,{disableExtensions:["elysia"]})});return r instanceof Response&&(r.headers.forEach((c,d)=>{p.headers[d]=c}),p.status=r.status),r}})};export{g as elysia};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Elysia, Context as ElysiaContext } from \"elysia\";\nimport type { Server, Extension } from \"@niledatabase/server\";\n\nconst cleaner = (val: string) => val.replaceAll(/\\{([^}]+)\\}/g, \":$1\");\n\nexport const elysia = (app: Elysia): Extension => {\n let instance: Server;\n\n return () => ({\n id: \"elysia\",\n onConfigure: (server: Server) => {\n instance = server;\n\n const paths = {\n get: instance.paths.get.map(cleaner),\n post: instance.paths.post.map(cleaner),\n put: instance.paths.put.map(cleaner),\n delete: instance.paths.delete.map(cleaner),\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handlers = instance.handlers as any;\n\n paths.get.forEach((path) => app.get(path, handlers.GET));\n paths.post.forEach((path) => app.post(path, handlers.POST));\n paths.put.forEach((path) => app.put(path, handlers.PUT));\n paths.delete.forEach((path) => app.delete(path, handlers.DELETE));\n },\n\n onHandleRequest: async (params?: unknown[]) => {\n if (!instance) return;\n const arg = params?.[0];\n\n // If it's a raw Request, we let Nile handle it natively (or another extension)\n if (arg instanceof Request) {\n return;\n }\n\n // Check if it looks like an Elysia context\n // Elysia context has 'request', 'store', 'set', etc.\n // We do a loose check\n const ctx = arg as ElysiaContext;\n if (!ctx || typeof ctx !== \"object\" || !ctx.request || !ctx.set) {\n return;\n }\n\n const { request, params: pathParams, set } = ctx;\n const tenantId = pathParams?.tenantId;\n const headers = new Headers(request.headers);\n\n const context = {\n headers,\n tenantId,\n };\n\n const response = await instance.withContext(context, async (nileCtx) => {\n const method = request.method as \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n\n return (await nileCtx.handlers[method](request, {\n disableExtensions: [\"elysia\"],\n })) as Response;\n });\n\n if (response instanceof Response) {\n response.headers.forEach((value, key) => {\n set.headers[key] = value;\n });\n set.status = response.status;\n return response;\n }\n return response;\n },\n });\n};\n"],"mappings":"AAGA,IAAMA,EAAWC,GAAgBA,EAAI,WAAW,eAAgB,KAAK,EAExDC,EAAUC,GAA2B,CAChD,IAAIC,EAEJ,MAAO,KAAO,CACZ,GAAI,SACJ,YAAcC,GAAmB,CAC/BD,EAAWC,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Elysia, Context as ElysiaContext } from \"elysia\";\nimport type { Server, Extension } from \"@niledatabase/server\";\n\nconst cleaner = (val: string) => val.replaceAll(/\\{([^}]+)\\}/g, \":$1\");\n\nexport const elysia = (app: Elysia): Extension => {\n let instance: Server;\n\n return () => ({\n id: \"elysia\",\n onConfigure: (server: Server) => {\n instance = server;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (typeof Bun !== \"undefined\") {\n instance.skipHostHeader = true;\n }\n\n const paths = {\n get: instance.paths.get.map(cleaner),\n post: instance.paths.post.map(cleaner),\n put: instance.paths.put.map(cleaner),\n delete: instance.paths.delete.map(cleaner),\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handlers = instance.handlers as any;\n\n paths.get.forEach((path) => app.get(path, handlers.GET));\n paths.post.forEach((path) => app.post(path, handlers.POST));\n paths.put.forEach((path) => app.put(path, handlers.PUT));\n paths.delete.forEach((path) => app.delete(path, handlers.DELETE));\n },\n\n onHandleRequest: async (params?: unknown[]) => {\n const { error, debug } = instance?.logger?.(\"[elysia]\") ?? {\n error: () => null,\n debug: () => null,\n };\n\n if (!instance) {\n error(\n \"No Nile instance passed on initialization, was onConfigure called?\"\n );\n return;\n }\n\n const arg = params?.[0];\n\n // If it's a raw Request, we let Nile handle it natively (or another extension)\n if (arg instanceof Request) {\n debug(\"No request arg found\");\n return;\n }\n\n // Check if it looks like an Elysia context\n // Elysia context has 'request', 'store', 'set', etc.\n // We do a loose check\n const ctx = arg as ElysiaContext;\n if (!ctx || typeof ctx !== \"object\" || !ctx.request || !ctx.set) {\n error(\"No Elysia context found, unable to handle request\");\n return;\n }\n\n const { request, params: pathParams, set } = ctx;\n const tenantId = pathParams?.tenantId;\n const headers = new Headers(request.headers);\n\n const context = {\n headers,\n tenantId,\n };\n\n const response = await instance.withContext(context, async (nileCtx) => {\n const method = request.method as \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n\n return (await nileCtx.handlers[method](request, {\n disableExtensions: [\"elysia\"],\n })) as Response;\n });\n\n if (response instanceof Response) {\n response.headers.forEach((value, key) => {\n set.headers[key] = value;\n });\n set.status = response.status;\n return response;\n }\n return response;\n },\n });\n};\n"],"mappings":"AAGA,IAAMA,EAAWC,GAAgBA,EAAI,WAAW,eAAgB,KAAK,EAExDC,EAAUC,GAA2B,CAChD,IAAIC,EAEJ,MAAO,KAAO,CACZ,GAAI,SACJ,YAAcC,GAAmB,CAC/BD,EAAWC,EAGP,OAAO,IAAQ,MACjBD,EAAS,eAAiB,IAG5B,IAAME,EAAQ,CACZ,IAAKF,EAAS,MAAM,IAAI,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EAED,OAAIK,aAAoB,WACtBA,EAAS,QAAQ,QAAQ,CAACG,EAAOC,IAAQ,CACvCP,EAAI,QAAQO,CAAG,EAAID,CACrB,CAAC,EACDN,EAAI,OAASG,EAAS,QACfA,CAGX,CACF,EACF","names":["cleaner","val","elysia","app","instance","server","paths","handlers","path","params","error","debug","arg","ctx","request","pathParams","set","tenantId","context","response","nileCtx","method","value","key"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@niledatabase/elysia",
|
|
3
|
-
"version": "5.3.1-alpha.
|
|
3
|
+
"version": "5.3.1-alpha.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@elysiajs/node": "^1.4.2",
|
|
35
|
-
"@niledatabase/server": "^5.3.1-alpha.
|
|
35
|
+
"@niledatabase/server": "^5.3.1-alpha.3",
|
|
36
36
|
"@sinclair/typebox": "^0.34.45",
|
|
37
37
|
"@types/jest": "^29.5.12",
|
|
38
38
|
"dotenv": "^17.2.3",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"tsup": "^8.0.0",
|
|
43
43
|
"typescript": "^5.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "5f571ef9164c10b8147f0b6fd06f390a6a962bf7"
|
|
46
46
|
}
|