@niledatabase/elysia 5.3.1-alpha.4 → 5.3.1-alpha.5
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.d.mts +32 -3
- package/dist/index.d.ts +32 -3
- 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 +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import {
|
|
2
|
+
import { Server } from '@niledatabase/server';
|
|
3
3
|
|
|
4
|
-
declare const
|
|
4
|
+
declare const nilePlugin: <S extends Server>(nile: S) => Elysia<"", {
|
|
5
|
+
decorator: {
|
|
6
|
+
nile: S;
|
|
7
|
+
};
|
|
8
|
+
store: {};
|
|
9
|
+
derive: {};
|
|
10
|
+
resolve: {};
|
|
11
|
+
}, {
|
|
12
|
+
typebox: {};
|
|
13
|
+
error: {};
|
|
14
|
+
}, {
|
|
15
|
+
schema: {};
|
|
16
|
+
standaloneSchema: {};
|
|
17
|
+
macro: {};
|
|
18
|
+
macroFn: {};
|
|
19
|
+
parser: {};
|
|
20
|
+
response: {};
|
|
21
|
+
}, {}, {
|
|
22
|
+
derive: {};
|
|
23
|
+
resolve: {};
|
|
24
|
+
schema: {};
|
|
25
|
+
standaloneSchema: {};
|
|
26
|
+
response: {};
|
|
27
|
+
}, {
|
|
28
|
+
derive: {};
|
|
29
|
+
resolve: {};
|
|
30
|
+
schema: {};
|
|
31
|
+
standaloneSchema: {};
|
|
32
|
+
response: {};
|
|
33
|
+
}>;
|
|
5
34
|
|
|
6
|
-
export {
|
|
35
|
+
export { nilePlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import {
|
|
2
|
+
import { Server } from '@niledatabase/server';
|
|
3
3
|
|
|
4
|
-
declare const
|
|
4
|
+
declare const nilePlugin: <S extends Server>(nile: S) => Elysia<"", {
|
|
5
|
+
decorator: {
|
|
6
|
+
nile: S;
|
|
7
|
+
};
|
|
8
|
+
store: {};
|
|
9
|
+
derive: {};
|
|
10
|
+
resolve: {};
|
|
11
|
+
}, {
|
|
12
|
+
typebox: {};
|
|
13
|
+
error: {};
|
|
14
|
+
}, {
|
|
15
|
+
schema: {};
|
|
16
|
+
standaloneSchema: {};
|
|
17
|
+
macro: {};
|
|
18
|
+
macroFn: {};
|
|
19
|
+
parser: {};
|
|
20
|
+
response: {};
|
|
21
|
+
}, {}, {
|
|
22
|
+
derive: {};
|
|
23
|
+
resolve: {};
|
|
24
|
+
schema: {};
|
|
25
|
+
standaloneSchema: {};
|
|
26
|
+
response: {};
|
|
27
|
+
}, {
|
|
28
|
+
derive: {};
|
|
29
|
+
resolve: {};
|
|
30
|
+
schema: {};
|
|
31
|
+
standaloneSchema: {};
|
|
32
|
+
response: {};
|
|
33
|
+
}>;
|
|
5
34
|
|
|
6
|
-
export {
|
|
35
|
+
export { nilePlugin };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var w=(e,t)=>{for(var a in t)c(e,a,{get:t[a],enumerable:!0})},g=(e,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of l(t))!S.call(e,s)&&s!==a&&c(e,s,{get:()=>t[s],enumerable:!(r=P(t,s))||r.enumerable});return e};var x=e=>g(c({},"__esModule",{value:!0}),e);var D={};w(D,{nilePlugin:()=>y});module.exports=x(D);var h=require("elysia"),o=e=>e.replaceAll(/\{([^}]+)\}/g,":$1"),y=e=>{if(!e)throw new Error("Nile instance is required. usage: nile(myNile)");typeof Bun<"u"&&(e.skipHostHeader=!0);let t=new h.Elysia({name:"nile",seed:e}).decorate("nile",e),a={GET:e.paths.get.map(o),POST:e.paths.post.map(o),PUT:e.paths.put.map(o),DELETE:e.paths.delete.map(o)},r=s=>async i=>{let{request:E,params:T,set:d}=i,u=T?.tenantId,f={headers:new Headers(E.headers),tenantId:u},n=await e.withContext(f,async p=>await p.handlers[s](E));return n instanceof Response&&(n.headers.forEach((p,m)=>{d.headers[m]=p}),d.status=n.status),n};return a.GET.forEach(s=>t.get(s,r("GET"))),a.POST.forEach(s=>t.post(s,r("POST"))),a.PUT.forEach(s=>t.put(s,r("PUT"))),a.DELETE.forEach(s=>t.delete(s,r("DELETE"))),t};0&&(module.exports={nilePlugin});
|
|
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
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Elysia, Context } from \"elysia\";\nimport type { Server } from \"@niledatabase/server\";\n\nconst cleaner = (val: string) => val.replaceAll(/\\{([^}]+)\\}/g, \":$1\");\n\nexport const nilePlugin = <S extends Server>(nile: S) => {\n if (!nile) {\n throw new Error(\"Nile instance is required. usage: nile(myNile)\");\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (typeof Bun !== \"undefined\") {\n nile.skipHostHeader = true;\n }\n\n const app = new Elysia({\n name: \"nile\",\n seed: nile,\n }).decorate(\"nile\", nile);\n\n const paths = {\n GET: nile.paths.get.map(cleaner),\n POST: nile.paths.post.map(cleaner),\n PUT: nile.paths.put.map(cleaner),\n DELETE: nile.paths.delete.map(cleaner),\n };\n\n const createHandler =\n (method: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\") => async (ctx: Context) => {\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 nile.withContext(context, async (nileCtx) => {\n return (await nileCtx.handlers[method](request)) 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 paths.GET.forEach((path) => app.get(path, createHandler(\"GET\")));\n paths.POST.forEach((path) => app.post(path, createHandler(\"POST\")));\n paths.PUT.forEach((path) => app.put(path, createHandler(\"PUT\")));\n paths.DELETE.forEach((path) => app.delete(path, createHandler(\"DELETE\")));\n\n return app;\n};\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,kBAG1BC,EAAWC,GAAgBA,EAAI,WAAW,eAAgB,KAAK,EAExDJ,EAAgCK,GAAY,CACvD,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,gDAAgD,EAK9D,OAAO,IAAQ,MACjBA,EAAK,eAAiB,IAGxB,IAAMC,EAAM,IAAI,SAAO,CACrB,KAAM,OACN,KAAMD,CACR,CAAC,EAAE,SAAS,OAAQA,CAAI,EAElBE,EAAQ,CACZ,IAAKF,EAAK,MAAM,IAAI,IAAIF,CAAO,EAC/B,KAAME,EAAK,MAAM,KAAK,IAAIF,CAAO,EACjC,IAAKE,EAAK,MAAM,IAAI,IAAIF,CAAO,EAC/B,OAAQE,EAAK,MAAM,OAAO,IAAIF,CAAO,CACvC,EAEMK,EACHC,GAA8C,MAAOC,GAAiB,CACrE,GAAM,CAAE,QAAAC,EAAS,OAAQC,EAAY,IAAAC,CAAI,EAAIH,EACvCI,EAAWF,GAAY,SAGvBG,EAAU,CACd,QAHc,IAAI,QAAQJ,EAAQ,OAAO,EAIzC,SAAAG,CACF,EAEME,EAAW,MAAMX,EAAK,YAAYU,EAAS,MAAOE,GAC9C,MAAMA,EAAQ,SAASR,CAAM,EAAEE,CAAO,CAC/C,EAED,OAAIK,aAAoB,WACtBA,EAAS,QAAQ,QAAQ,CAACE,EAAOC,IAAQ,CACvCN,EAAI,QAAQM,CAAG,EAAID,CACrB,CAAC,EACDL,EAAI,OAASG,EAAS,QACfA,CAGX,EAEF,OAAAT,EAAM,IAAI,QAASa,GAASd,EAAI,IAAIc,EAAMZ,EAAc,KAAK,CAAC,CAAC,EAC/DD,EAAM,KAAK,QAASa,GAASd,EAAI,KAAKc,EAAMZ,EAAc,MAAM,CAAC,CAAC,EAClED,EAAM,IAAI,QAASa,GAASd,EAAI,IAAIc,EAAMZ,EAAc,KAAK,CAAC,CAAC,EAC/DD,EAAM,OAAO,QAASa,GAASd,EAAI,OAAOc,EAAMZ,EAAc,QAAQ,CAAC,CAAC,EAEjEF,CACT","names":["index_exports","__export","nilePlugin","__toCommonJS","import_elysia","cleaner","val","nile","app","paths","createHandler","method","ctx","request","pathParams","set","tenantId","context","response","nileCtx","value","key","path"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
import{Elysia as f}from"elysia";var o=e=>e.replaceAll(/\{([^}]+)\}/g,":$1"),S=e=>{if(!e)throw new Error("Nile instance is required. usage: nile(myNile)");typeof Bun<"u"&&(e.skipHostHeader=!0);let s=new f({name:"nile",seed:e}).decorate("nile",e),r={GET:e.paths.get.map(o),POST:e.paths.post.map(o),PUT:e.paths.put.map(o),DELETE:e.paths.delete.map(o)},n=t=>async d=>{let{request:c,params:h,set:E}=d,i=h?.tenantId,T={headers:new Headers(c.headers),tenantId:i},a=await e.withContext(T,async p=>await p.handlers[t](c));return a instanceof Response&&(a.headers.forEach((p,u)=>{E.headers[u]=p}),E.status=a.status),a};return r.GET.forEach(t=>s.get(t,n("GET"))),r.POST.forEach(t=>s.post(t,n("POST"))),r.PUT.forEach(t=>s.put(t,n("PUT"))),r.DELETE.forEach(t=>s.delete(t,n("DELETE"))),s};export{S as nilePlugin};
|
|
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
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Elysia, Context } from \"elysia\";\nimport type { Server } from \"@niledatabase/server\";\n\nconst cleaner = (val: string) => val.replaceAll(/\\{([^}]+)\\}/g, \":$1\");\n\nexport const nilePlugin = <S extends Server>(nile: S) => {\n if (!nile) {\n throw new Error(\"Nile instance is required. usage: nile(myNile)\");\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (typeof Bun !== \"undefined\") {\n nile.skipHostHeader = true;\n }\n\n const app = new Elysia({\n name: \"nile\",\n seed: nile,\n }).decorate(\"nile\", nile);\n\n const paths = {\n GET: nile.paths.get.map(cleaner),\n POST: nile.paths.post.map(cleaner),\n PUT: nile.paths.put.map(cleaner),\n DELETE: nile.paths.delete.map(cleaner),\n };\n\n const createHandler =\n (method: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\") => async (ctx: Context) => {\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 nile.withContext(context, async (nileCtx) => {\n return (await nileCtx.handlers[method](request)) 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 paths.GET.forEach((path) => app.get(path, createHandler(\"GET\")));\n paths.POST.forEach((path) => app.post(path, createHandler(\"POST\")));\n paths.PUT.forEach((path) => app.put(path, createHandler(\"PUT\")));\n paths.DELETE.forEach((path) => app.delete(path, createHandler(\"DELETE\")));\n\n return app;\n};\n"],"mappings":"AAAA,OAAS,UAAAA,MAAuB,SAGhC,IAAMC,EAAWC,GAAgBA,EAAI,WAAW,eAAgB,KAAK,EAExDC,EAAgCC,GAAY,CACvD,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,gDAAgD,EAK9D,OAAO,IAAQ,MACjBA,EAAK,eAAiB,IAGxB,IAAMC,EAAM,IAAIL,EAAO,CACrB,KAAM,OACN,KAAMI,CACR,CAAC,EAAE,SAAS,OAAQA,CAAI,EAElBE,EAAQ,CACZ,IAAKF,EAAK,MAAM,IAAI,IAAIH,CAAO,EAC/B,KAAMG,EAAK,MAAM,KAAK,IAAIH,CAAO,EACjC,IAAKG,EAAK,MAAM,IAAI,IAAIH,CAAO,EAC/B,OAAQG,EAAK,MAAM,OAAO,IAAIH,CAAO,CACvC,EAEMM,EACHC,GAA8C,MAAOC,GAAiB,CACrE,GAAM,CAAE,QAAAC,EAAS,OAAQC,EAAY,IAAAC,CAAI,EAAIH,EACvCI,EAAWF,GAAY,SAGvBG,EAAU,CACd,QAHc,IAAI,QAAQJ,EAAQ,OAAO,EAIzC,SAAAG,CACF,EAEME,EAAW,MAAMX,EAAK,YAAYU,EAAS,MAAOE,GAC9C,MAAMA,EAAQ,SAASR,CAAM,EAAEE,CAAO,CAC/C,EAED,OAAIK,aAAoB,WACtBA,EAAS,QAAQ,QAAQ,CAACE,EAAOC,IAAQ,CACvCN,EAAI,QAAQM,CAAG,EAAID,CACrB,CAAC,EACDL,EAAI,OAASG,EAAS,QACfA,CAGX,EAEF,OAAAT,EAAM,IAAI,QAASa,GAASd,EAAI,IAAIc,EAAMZ,EAAc,KAAK,CAAC,CAAC,EAC/DD,EAAM,KAAK,QAASa,GAASd,EAAI,KAAKc,EAAMZ,EAAc,MAAM,CAAC,CAAC,EAClED,EAAM,IAAI,QAASa,GAASd,EAAI,IAAIc,EAAMZ,EAAc,KAAK,CAAC,CAAC,EAC/DD,EAAM,OAAO,QAASa,GAASd,EAAI,OAAOc,EAAMZ,EAAc,QAAQ,CAAC,CAAC,EAEjEF,CACT","names":["Elysia","cleaner","val","nilePlugin","nile","app","paths","createHandler","method","ctx","request","pathParams","set","tenantId","context","response","nileCtx","value","key","path"]}
|
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.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "tsup src/index.ts",
|
|
19
|
-
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
|
|
19
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --forceExit"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@niledatabase/server": ">=5.2.0",
|
|
@@ -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.5",
|
|
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": "d9ed138b1dd02599fce37c973c199cc853f8987f"
|
|
46
46
|
}
|