gemi 0.4.12 → 0.4.13

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 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../app/App.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAsB,MAAM,oBAAoB,CAAC;AAKpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAU3C,OAAO,EAAE,aAAa,EAA2B,MAAM,OAAO,CAAC;AAI/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,UAAU,SAAS;IACjB,UAAU,EAAE,UAAU,UAAU,CAAC;IACjC,SAAS,EAAE,UAAU,SAAS,CAAC;IAC/B,OAAO,CAAC,EAAE,CAAC,UAAU,MAAM,CAAC,EAAE,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,UAAU,CAAC,CAAC;IACzD,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,UAAU,MAAM,CAAC;CAC1B;AAED,qBAAa,GAAG;IACd,OAAO,CAAC,YAAY,CAKlB;IACF,OAAO,CAAC,cAAc,CAGf;IACP,OAA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AAY;YAI7B,eAAe;IAqC7B,OAAO,CAAC,aAAa;IAmCf,gBAAgB,CAAC,GAAG,EAAE,OAAO;IAyF7B,iBAAiB,CAAC,GAAG,EAAE,OAAO;IAmL9B,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAY5C,OAAO,CAAC,sBAAsB,CAGtB;IACR,OAAO,CAAC,mBAAmB,CAEzB;IACF,OAAO,CAAC,oBAAoB,CAM1B;IAEF,SAAS;sBAdH,eAAe,WACV,MAAM,GAAG,MAAM;mBAES,eAAe;oBAI5C,eAAe,QACb,MAAM,UACJ,MAAM;MASd;CACH"}
@@ -1,8 +1,10 @@
1
1
  import { Middleware } from "../http";
2
- import { ApiRouteChildren, ApiRouteExec } from "../http/ApiRouter";
2
+ import { ApiRoutes } from "../http/ApiRouter";
3
3
  import { RouterMiddleware } from "../http/Router";
4
- export declare function createFlatApiRoutes(routes: ApiRouteChildren): Record<string, Record<string, {
4
+ type ApiRouteExec = any;
5
+ export declare function createFlatApiRoutes(routes: ApiRoutes): Record<string, Record<string, {
5
6
  exec: ApiRouteExec;
6
7
  middleware: (string | (new () => Middleware) | RouterMiddleware)[];
7
8
  }>>;
9
+ export {};
8
10
  //# sourceMappingURL=createFlatApiRoutes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createFlatApiRoutes.d.ts","sourceRoot":"","sources":["../../app/createFlatApiRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB;UAM9C,YAAY;gBACN,CAAC,MAAM,GAAG,CAAC,UAAU,UAAU,CAAC,GAAG,gBAAgB,CAAC,EAAE;IAoDzE"}
1
+ {"version":3,"file":"createFlatApiRoutes.d.ts","sourceRoot":"","sources":["../../app/createFlatApiRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAgB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,KAAK,YAAY,GAAG,GAAG,CAAC;AAExB,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS;UAMvC,YAAY;gBACN,CAAC,MAAM,GAAG,CAAC,UAAU,UAAU,CAAC,GAAG,gBAAgB,CAAC,EAAE;IAyDzE"}
package/dist/app/index.js CHANGED
@@ -491,11 +491,148 @@ var require_dist = __commonJS((exports) => {
491
491
 
492
492
  // http/Controller.ts
493
493
  class Controller {
494
- app;
495
494
  requests = {};
496
495
  static kind = "controller";
497
- constructor(app) {
498
- this.app = app;
496
+ constructor() {
497
+ }
498
+ }
499
+ // internal/isConstructor.ts
500
+ function isConstructor(value) {
501
+ return typeof value === "function" && value.prototype !== undefined;
502
+ }
503
+
504
+ // http/ApiRouter.ts
505
+ var isController = function(candidate) {
506
+ return isConstructor(candidate);
507
+ };
508
+
509
+ class RouteHandler {
510
+ method;
511
+ handler;
512
+ methodName;
513
+ middlewares = [];
514
+ constructor(method, handler, methodName) {
515
+ this.method = method;
516
+ this.handler = handler;
517
+ this.methodName = methodName;
518
+ }
519
+ run(req) {
520
+ let httpRequest = req;
521
+ if (isController(this.handler)) {
522
+ const controller = new this.handler;
523
+ const handler = controller[this.methodName].bind(controller);
524
+ httpRequest = controller.requests[this.methodName] ? new controller.requests[this.methodName](req.rawRequest, req.params) : httpRequest;
525
+ return handler(httpRequest);
526
+ } else {
527
+ return this.handler(req);
528
+ }
529
+ }
530
+ middleware(middlewareList) {
531
+ this.middlewares = middlewareList;
532
+ return this;
533
+ }
534
+ }
535
+
536
+ class ApiRouter {
537
+ routes = {};
538
+ middlewares = [];
539
+ middleware(_req) {
540
+ }
541
+ get(handler, methodName) {
542
+ return new RouteHandler("GET", handler, methodName);
543
+ }
544
+ post(handler, methodName) {
545
+ return new RouteHandler("POST", handler, methodName);
546
+ }
547
+ put(handler, methodName) {
548
+ return new RouteHandler("PUT", handler, methodName);
549
+ }
550
+ patch(handler, methodName) {
551
+ return new RouteHandler("PATCH", handler, methodName);
552
+ }
553
+ delete(handler, methodName) {
554
+ return new RouteHandler("DELETE", handler, methodName);
555
+ }
556
+ }
557
+ // http/ViewRouter.ts
558
+ class ViewRouter {
559
+ routes = {};
560
+ middlewares = [];
561
+ middleware(req) {
562
+ }
563
+ layout(viewPath, handler, children) {
564
+ function prepare(middlewares = []) {
565
+ let _children = children ?? {};
566
+ if (handler && handler.constructor === Object) {
567
+ _children = handler;
568
+ }
569
+ return {
570
+ exec: async (req, params, app) => {
571
+ let _handler = () => Promise.resolve({
572
+ data: { [viewPath]: {} },
573
+ headers: {},
574
+ head: {}
575
+ });
576
+ if (typeof handler === "function") {
577
+ _handler = handler;
578
+ }
579
+ if (Array.isArray(handler)) {
580
+ const [controller, methodName] = handler;
581
+ const instance = new controller(app);
582
+ _handler = instance[methodName].bind(instance);
583
+ }
584
+ const data = await _handler(req, params);
585
+ return { [viewPath]: data };
586
+ },
587
+ children: _children,
588
+ viewPath,
589
+ middlewares,
590
+ kind: "layout"
591
+ };
592
+ }
593
+ return {
594
+ prepare,
595
+ middleware: (middlewares) => ({
596
+ prepare: () => prepare(middlewares)
597
+ })
598
+ };
599
+ }
600
+ view(viewPath, handler, children) {
601
+ function prepare(middlewares = []) {
602
+ let _children = children ?? {};
603
+ if (handler && handler.constructor === Object) {
604
+ _children = handler;
605
+ }
606
+ return {
607
+ exec: async (req, params, app) => {
608
+ let _handler = () => Promise.resolve({
609
+ data: { [viewPath]: {} },
610
+ headers: {},
611
+ head: {}
612
+ });
613
+ if (typeof handler === "function") {
614
+ _handler = handler;
615
+ }
616
+ if (Array.isArray(handler)) {
617
+ const [controller, methodName] = handler;
618
+ const instance = new controller(app);
619
+ _handler = instance[methodName].bind(instance);
620
+ }
621
+ const data = await _handler(req, params);
622
+ return { [viewPath]: data };
623
+ },
624
+ children: _children,
625
+ viewPath,
626
+ middlewares,
627
+ kind: "view"
628
+ };
629
+ }
630
+ return {
631
+ prepare,
632
+ middleware: (middlewares) => ({
633
+ prepare: () => prepare(middlewares)
634
+ })
635
+ };
499
636
  }
500
637
  }
501
638
  // http/Error.ts
@@ -555,7 +692,6 @@ class ValidationError extends RequestBreakerError {
555
692
  };
556
693
  }
557
694
  }
558
-
559
695
  // http/HttpRequest.ts
560
696
  var validate = function(ruleName) {
561
697
  const [rule, param] = ruleName.split(":");
@@ -593,12 +729,22 @@ var validate = function(ruleName) {
593
729
  }
594
730
  };
595
731
 
596
- class Input extends Map {
597
- constructor() {
598
- super();
732
+ class Input {
733
+ data;
734
+ constructor(data) {
735
+ this.data = data;
736
+ }
737
+ get(key) {
738
+ return this.data[key];
739
+ }
740
+ set(key, value) {
741
+ this.data[key] = value;
742
+ }
743
+ has(key) {
744
+ return this.data[key] !== undefined;
599
745
  }
600
746
  toJSON() {
601
- return Object.fromEntries(this);
747
+ return this.data;
602
748
  }
603
749
  }
604
750
 
@@ -606,8 +752,10 @@ class HttpRequest {
606
752
  rawRequest;
607
753
  headers;
608
754
  cookies;
609
- schema = {};
610
- constructor(req) {
755
+ schema;
756
+ params;
757
+ constructor(req, params) {
758
+ this.params = params;
611
759
  this.rawRequest = req;
612
760
  this.headers = req.headers;
613
761
  const cookie = this.rawRequest.headers.get("Cookie");
@@ -622,7 +770,7 @@ class HttpRequest {
622
770
  this.cookies = cookies;
623
771
  }
624
772
  async parseBody() {
625
- const inputMap = new Input;
773
+ const inputMap = new Input({});
626
774
  if (this.rawRequest.headers.get("Content-Type") === "application/json") {
627
775
  const body = await this.rawRequest.json();
628
776
  for (const [key, value] of Object.entries(body)) {
@@ -702,152 +850,6 @@ class HttpRequest {
702
850
  throw "not implemented";
703
851
  }
704
852
  }
705
-
706
- // http/ApiRouter.ts
707
- var isController = function(controller) {
708
- return "kind" in controller && controller.kind === "controller";
709
- };
710
-
711
- class ApiRouter {
712
- routes = {};
713
- middlewares = [];
714
- constructor() {
715
- }
716
- middleware(_req) {
717
- }
718
- handleRequest(controller, methodName) {
719
- return (method) => {
720
- const prepare = (middleware = []) => {
721
- return {
722
- middleware,
723
- method,
724
- exec: async (req, params, app) => {
725
- let handler = (_req, params2) => Promise.resolve({});
726
- let httpRequest = new HttpRequest(req.rawRequest);
727
- if (isController(controller)) {
728
- const controllerInstance = new controller(app);
729
- const Req = controllerInstance.requests[methodName] ?? HttpRequest;
730
- httpRequest = new Req(req.rawRequest);
731
- handler = controllerInstance[methodName].bind(controllerInstance);
732
- } else if (typeof controller === "function") {
733
- handler = (req2) => controller(req2);
734
- }
735
- return await handler(httpRequest, params);
736
- }
737
- };
738
- };
739
- return {
740
- prepare,
741
- middleware: (middlware) => {
742
- return {
743
- prepare: () => prepare(middlware)
744
- };
745
- }
746
- };
747
- };
748
- }
749
- get(controller, methodName) {
750
- const handler = this.handleRequest(controller, methodName);
751
- return handler("get");
752
- }
753
- post(controller, methodName) {
754
- const handler = this.handleRequest(controller, methodName);
755
- return handler("post");
756
- }
757
- put(controller, methodName) {
758
- const handler = this.handleRequest(controller, methodName);
759
- return handler("put");
760
- }
761
- delete(controller, methodName) {
762
- const handler = this.handleRequest(controller, methodName);
763
- return handler("delete");
764
- }
765
- patch(controller, methodName) {
766
- const handler = this.handleRequest(controller, methodName);
767
- return handler("patch");
768
- }
769
- }
770
- // http/ViewRouter.ts
771
- class ViewRouter {
772
- routes = {};
773
- middlewares = [];
774
- middleware(req) {
775
- }
776
- layout(viewPath, handler, children) {
777
- function prepare(middlewares = []) {
778
- let _children = children ?? {};
779
- if (handler && handler.constructor === Object) {
780
- _children = handler;
781
- }
782
- return {
783
- exec: async (req, params, app) => {
784
- let _handler = () => Promise.resolve({
785
- data: { [viewPath]: {} },
786
- headers: {},
787
- head: {}
788
- });
789
- if (typeof handler === "function") {
790
- _handler = handler;
791
- }
792
- if (Array.isArray(handler)) {
793
- const [controller, methodName] = handler;
794
- const instance = new controller(app);
795
- _handler = instance[methodName].bind(instance);
796
- }
797
- const data = await _handler(req, params);
798
- return { [viewPath]: data };
799
- },
800
- children: _children,
801
- viewPath,
802
- middlewares,
803
- kind: "layout"
804
- };
805
- }
806
- return {
807
- prepare,
808
- middleware: (middlewares) => ({
809
- prepare: () => prepare(middlewares)
810
- })
811
- };
812
- }
813
- view(viewPath, handler, children) {
814
- function prepare(middlewares = []) {
815
- let _children = children ?? {};
816
- if (handler && handler.constructor === Object) {
817
- _children = handler;
818
- }
819
- return {
820
- exec: async (req, params, app) => {
821
- let _handler = () => Promise.resolve({
822
- data: { [viewPath]: {} },
823
- headers: {},
824
- head: {}
825
- });
826
- if (typeof handler === "function") {
827
- _handler = handler;
828
- }
829
- if (Array.isArray(handler)) {
830
- const [controller, methodName] = handler;
831
- const instance = new controller(app);
832
- _handler = instance[methodName].bind(instance);
833
- }
834
- const data = await _handler(req, params);
835
- return { [viewPath]: data };
836
- },
837
- children: _children,
838
- viewPath,
839
- middlewares,
840
- kind: "view"
841
- };
842
- }
843
- return {
844
- prepare,
845
- middleware: (middlewares) => ({
846
- prepare: () => prepare(middlewares)
847
- })
848
- };
849
- }
850
- }
851
853
  // http/Middleware.ts
852
854
  class Middleware {
853
855
  async run(_req, ctx) {
@@ -1791,29 +1793,34 @@ function createRouteManifest(routes) {
1791
1793
  // app/createFlatApiRoutes.ts
1792
1794
  function createFlatApiRoutes(routes) {
1793
1795
  const flatApiRoutes = {};
1794
- for (const [rootPath, apiConfigOrApiRouter] of Object.entries(routes)) {
1795
- if ("prepare" in apiConfigOrApiRouter) {
1796
+ for (const [rootPath, apiRouteHandlerOrApiRouter] of Object.entries(routes)) {
1797
+ if (apiRouteHandlerOrApiRouter instanceof RouteHandler) {
1798
+ const routeHandler = apiRouteHandlerOrApiRouter;
1796
1799
  if (!flatApiRoutes[rootPath]) {
1797
1800
  flatApiRoutes[rootPath] = {};
1798
1801
  }
1799
- const { exec, method, middleware } = apiConfigOrApiRouter.prepare();
1802
+ const method = routeHandler.method;
1803
+ const middleware = routeHandler.middlewares;
1804
+ const exec = routeHandler.run.bind(routeHandler);
1800
1805
  flatApiRoutes[rootPath][method] = {
1801
1806
  exec,
1802
1807
  middleware: [...middleware]
1803
1808
  };
1804
- } else if (Array.isArray(apiConfigOrApiRouter)) {
1805
- for (const apiConfig of apiConfigOrApiRouter) {
1809
+ } else if (Array.isArray(apiRouteHandlerOrApiRouter)) {
1810
+ for (const routeHandler of apiRouteHandlerOrApiRouter) {
1806
1811
  if (!flatApiRoutes[rootPath]) {
1807
1812
  flatApiRoutes[rootPath] = {};
1808
1813
  }
1809
- const { exec, method, middleware } = apiConfig.prepare();
1814
+ const method = routeHandler.method;
1815
+ const middleware = routeHandler.middlewares;
1816
+ const exec = routeHandler.run;
1810
1817
  flatApiRoutes[rootPath][method] = {
1811
1818
  exec,
1812
1819
  middleware
1813
1820
  };
1814
1821
  }
1815
1822
  } else {
1816
- const router = new apiConfigOrApiRouter;
1823
+ const router = new apiRouteHandlerOrApiRouter;
1817
1824
  const result = createFlatApiRoutes(router.routes);
1818
1825
  for (const [path, handlers] of Object.entries(result)) {
1819
1826
  const subPath = path === "/" ? "" : path;
@@ -1841,13 +1848,6 @@ function createFlatApiRoutes(routes) {
1841
1848
  // app/App.ts
1842
1849
  import {renderToReadableStream} from "react-dom/server.browser";
1843
1850
  import {createElement, Fragment} from "react";
1844
-
1845
- // internal/isConstructor.ts
1846
- function isConstructor(value) {
1847
- return typeof value === "function" && value.prototype !== undefined;
1848
- }
1849
-
1850
- // app/App.ts
1851
1851
  class App {
1852
1852
  renderParams = {
1853
1853
  styles: [],
@@ -1931,7 +1931,7 @@ class App {
1931
1931
  const reqWithMiddlewares = this.runMiddleware(middlewares);
1932
1932
  const reqCtx = new Map;
1933
1933
  const data = await requestContext.run(reqCtx, async () => {
1934
- await reqWithMiddlewares(new HttpRequest(req), reqCtx);
1934
+ await reqWithMiddlewares(new HttpRequest(req, params), reqCtx);
1935
1935
  return await Promise.all(handlers.map((fn) => fn(req, params, this)));
1936
1936
  });
1937
1937
  return {
@@ -1972,15 +1972,15 @@ class App {
1972
1972
  const pattern = new me({ pathname: path });
1973
1973
  if (pattern.test({ pathname: apiPath })) {
1974
1974
  const params = pattern.exec({ pathname: apiPath })?.pathname.groups;
1975
- if (!handler[req.method.toLowerCase()]) {
1975
+ if (!handler[req.method]) {
1976
1976
  return new Response(JSON.stringify({ error: { message: "Not found" } }));
1977
1977
  }
1978
- const exec = handler[req.method.toLowerCase()].exec;
1979
- const middlewares = handler[req.method.toLowerCase()].middleware;
1978
+ const exec = handler[req.method].exec;
1979
+ const middlewares = handler[req.method].middleware;
1980
1980
  const reqWithMiddlewares = this.runMiddleware(middlewares);
1981
1981
  const reqCtx = new Map;
1982
1982
  return await requestContext.run(reqCtx, async () => {
1983
- const httpRequest = new HttpRequest(req);
1983
+ const httpRequest = new HttpRequest(req, params);
1984
1984
  let handler2 = exec ? () => exec(httpRequest, params, this) : () => Promise.resolve({});
1985
1985
  try {
1986
1986
  await reqWithMiddlewares(httpRequest, reqCtx);
@@ -2058,7 +2058,7 @@ class App {
2058
2058
  const reqWithMiddlewares = this.runMiddleware(middlewares);
2059
2059
  const reqCtx = new Map;
2060
2060
  const data2 = await requestContext.run(reqCtx, async () => {
2061
- await reqWithMiddlewares(new HttpRequest(req), reqCtx);
2061
+ await reqWithMiddlewares(new HttpRequest(req, params2), reqCtx);
2062
2062
  return await Promise.all(handlers.map((fn) => fn(req, params2, this)));
2063
2063
  });
2064
2064
  pageData = {