@cleivermejia/backend 1.0.0 → 1.0.1

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.
Files changed (48) hide show
  1. package/dist/core/app.d.ts +9 -0
  2. package/dist/core/app.d.ts.map +1 -0
  3. package/dist/core/app.js +39 -0
  4. package/dist/core/app.js.map +1 -0
  5. package/dist/core/decorators.d.ts +4 -0
  6. package/dist/core/decorators.d.ts.map +1 -0
  7. package/dist/core/decorators.js +18 -0
  8. package/dist/core/decorators.js.map +1 -0
  9. package/dist/core/index.d.ts +2 -0
  10. package/dist/core/index.d.ts.map +1 -0
  11. package/dist/core/index.js +2 -0
  12. package/dist/core/index.js.map +1 -0
  13. package/dist/core/metadata.d.ts +7 -0
  14. package/dist/core/metadata.d.ts.map +1 -0
  15. package/dist/core/metadata.js +10 -0
  16. package/dist/core/metadata.js.map +1 -0
  17. package/dist/core/request.d.ts +5 -0
  18. package/dist/core/request.d.ts.map +1 -0
  19. package/dist/core/request.js +4 -0
  20. package/dist/core/request.js.map +1 -0
  21. package/dist/core/response.d.ts +9 -0
  22. package/dist/core/response.d.ts.map +1 -0
  23. package/dist/core/response.js +18 -0
  24. package/dist/core/response.js.map +1 -0
  25. package/dist/core/router.d.ts +9 -0
  26. package/dist/core/router.d.ts.map +1 -0
  27. package/dist/core/router.js +33 -0
  28. package/dist/core/router.js.map +1 -0
  29. package/dist/enum/method.d.ts +7 -0
  30. package/dist/enum/method.d.ts.map +1 -0
  31. package/dist/enum/method.js +8 -0
  32. package/dist/enum/method.js.map +1 -0
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +2 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/interface/route.d.ts +7 -0
  38. package/dist/interface/route.d.ts.map +1 -0
  39. package/dist/interface/route.js +2 -0
  40. package/dist/interface/route.js.map +1 -0
  41. package/dist/test.d.ts +2 -0
  42. package/dist/test.d.ts.map +1 -0
  43. package/dist/test.js +21 -0
  44. package/dist/test.js.map +1 -0
  45. package/package.json +7 -4
  46. package/src/core/index.ts +1 -0
  47. package/src/index.ts +1 -14
  48. package/tsconfig.json +3 -2
@@ -0,0 +1,9 @@
1
+ import { Router } from "./router";
2
+ export declare class App {
3
+ router: Router;
4
+ get(path: string, handler: Function): void;
5
+ put(path: string, handler: Function): void;
6
+ use(controller: Function): void;
7
+ listen(port: number, hostname?: string, handler?: (() => void) | undefined): void;
8
+ }
9
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/core/app.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAKlC,qBAAa,GAAG;IACP,MAAM,EAAE,MAAM,CAAgB;IAE9B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ;IAInC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ;IAInC,GAAG,CAAC,UAAU,EAAE,QAAQ;IAiBxB,MAAM,CACX,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS;CAgBrC"}
@@ -0,0 +1,39 @@
1
+ import { createServer, IncomingMessage, ServerResponse } from "http";
2
+ import { Response } from "./response";
3
+ import { Router } from "./router";
4
+ import { Request } from "./request";
5
+ import { Metadata } from "./metadata";
6
+ import { Method } from "../enum/method";
7
+ export class App {
8
+ router = new Router();
9
+ get(path, handler) {
10
+ this.router.get(path, handler);
11
+ }
12
+ put(path, handler) {
13
+ this.router.put(path, handler);
14
+ }
15
+ use(controller) {
16
+ const urlBase = Metadata.get(controller.prototype["constructor"])?.path ?? "";
17
+ Object.getOwnPropertyNames(controller.prototype)
18
+ .filter(m => m !== "constructor")
19
+ .forEach((f) => {
20
+ const functionController = controller.prototype[f];
21
+ const route = Metadata.get(functionController);
22
+ if (route && route.method === Method.GET) {
23
+ this.get(urlBase + route.path, (req, res) => {
24
+ res.send(functionController());
25
+ });
26
+ }
27
+ });
28
+ }
29
+ listen(port, hostname, handler) {
30
+ const server = createServer((req, res) => {
31
+ const route = this.router.routes.find((r) => req.method === r.method && req.url === r.path);
32
+ if (route?.handler) {
33
+ route.handler(new Request(req), new Response(res));
34
+ }
35
+ });
36
+ server.listen(port, hostname, handler);
37
+ }
38
+ }
39
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/core/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,MAAM,OAAO,GAAG;IACP,MAAM,GAAW,IAAI,MAAM,EAAE,CAAC;IAE9B,GAAG,CAAC,IAAY,EAAE,OAAiB;QACxC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IAEM,GAAG,CAAC,IAAY,EAAE,OAAiB;QACxC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IAEM,GAAG,CAAC,UAAoB;QAC7B,MAAM,OAAO,GAAW,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC;QAEtF,MAAM,CAAC,mBAAmB,CAAC,UAAU,CAAC,SAAS,CAAC;aAC/C,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,aAAa,CAAC;aAChC,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE;YACrB,MAAM,kBAAkB,GAAa,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC7D,MAAM,KAAK,GAAsB,QAAQ,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;YAElE,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC;gBACzC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE;oBAC7D,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC;gBACjC,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CACX,IAAY,EACZ,QAAiB,EACjB,OAAkC;QAElC,MAAM,MAAM,GAAG,YAAY,CACzB,CAAC,GAAoB,EAAE,GAAoC,EAAE,EAAE;YAC7D,MAAM,KAAK,GAAsB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CACtD,CAAC,CAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAC5D,CAAC;YAEF,IAAI,KAAK,EAAE,OAAO,EAAE,CAAC;gBACnB,KAAK,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;YACrD,CAAC;QACH,CAAC,CACF,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ declare function Controller(path: string): (constructor: Function) => void;
2
+ declare function Get(path?: string): <This, Args extends any[], Return>(value: (this: This, ...args: Args) => Return, context: ClassMethodDecoratorContext) => (this: This, ...args: Args) => Return;
3
+ export { Controller, Get };
4
+ //# sourceMappingURL=decorators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/core/decorators.ts"],"names":[],"mappings":"AAGA,iBAAS,UAAU,CAAC,IAAI,EAAE,MAAM,IACb,aAAa,QAAQ,UAGvC;AAED,iBAAS,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,IACP,IAAI,EAAE,IAAI,SAAS,GAAG,EAAE,EAAE,MAAM,EAC/C,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,EAC5C,SAAS,2BAA2B,YADtB,IAAI,WAAW,IAAI,KAAK,MAAM,CAU/C;AAED,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { Method } from "../enum/method";
2
+ import { Metadata } from "./metadata";
3
+ function Controller(path) {
4
+ return function (constructor) {
5
+ Metadata.set(constructor, { method: Method.GET, path });
6
+ };
7
+ }
8
+ function Get(path) {
9
+ return function (value, context) {
10
+ Metadata.set(value, {
11
+ method: Method.GET,
12
+ path: path ?? "",
13
+ });
14
+ return value;
15
+ };
16
+ }
17
+ export { Controller, Get };
18
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/core/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,UAAU,WAAqB;QACpC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,GAAG,CAAC,IAAa;IACxB,OAAO,UACL,KAA4C,EAC5C,OAAoC;QAEpC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE;YAClB,MAAM,EAAE,MAAM,CAAC,GAAG;YAClB,IAAI,EAAE,IAAI,IAAI,EAAE;SACjB,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,IAAI,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,IAAI,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Route } from "../interface/route";
2
+ export declare class Metadata {
3
+ private static weakMap;
4
+ static set(target: Function, value: Route): void;
5
+ static get(target: Function): Route | undefined;
6
+ }
7
+ //# sourceMappingURL=metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/core/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,qBAAa,QAAQ;IACjB,OAAO,CAAC,MAAM,CAAC,OAAO,CAA2C;WAEnD,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK;WAIlC,GAAG,CAAC,MAAM,EAAE,QAAQ;CAGrC"}
@@ -0,0 +1,10 @@
1
+ export class Metadata {
2
+ static weakMap = new WeakMap();
3
+ static set(target, value) {
4
+ Metadata.weakMap.set(target, value);
5
+ }
6
+ static get(target) {
7
+ return Metadata.weakMap.get(target);
8
+ }
9
+ }
10
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/core/metadata.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,QAAQ;IACT,MAAM,CAAC,OAAO,GAA6B,IAAI,OAAO,EAAE,CAAC;IAE1D,MAAM,CAAC,GAAG,CAAC,MAAgB,EAAE,KAAY;QAC5C,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAEM,MAAM,CAAC,GAAG,CAAC,MAAgB;QAC9B,OAAO,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { IncomingMessage } from "http";
2
+ export declare class Request {
3
+ constructor(req: IncomingMessage);
4
+ }
5
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/core/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAE5C,qBAAa,OAAO;gBACJ,GAAG,EAAE,eAAe;CACnC"}
@@ -0,0 +1,4 @@
1
+ export class Request {
2
+ constructor(req) { }
3
+ }
4
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/core/request.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,OAAO;IAChB,YAAY,GAAoB,IAAG,CAAC;CACvC"}
@@ -0,0 +1,9 @@
1
+ import type { ServerResponse } from "http";
2
+ export declare class Response {
3
+ private res;
4
+ constructor(res: ServerResponse);
5
+ json(data: unknown): void;
6
+ html(text: string): void;
7
+ send(text: string): void;
8
+ }
9
+ //# sourceMappingURL=response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/core/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE3C,qBAAa,QAAQ;IACP,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,cAAc;IAEhC,IAAI,CAAC,IAAI,EAAE,OAAO;IAKlB,IAAI,CAAC,IAAI,EAAE,MAAM;IAKjB,IAAI,CAAC,IAAI,EAAE,MAAM;CAGzB"}
@@ -0,0 +1,18 @@
1
+ export class Response {
2
+ res;
3
+ constructor(res) {
4
+ this.res = res;
5
+ }
6
+ json(data) {
7
+ this.res.setHeader("Content-Type", "application/json");
8
+ this.res.end(JSON.stringify(data));
9
+ }
10
+ html(text) {
11
+ this.res.setHeader("Content-Type", "text/html");
12
+ this.res.end(text);
13
+ }
14
+ send(text) {
15
+ this.res.end(text.toString());
16
+ }
17
+ }
18
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/core/response.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,QAAQ;IACC;IAApB,YAAoB,GAAmB;QAAnB,QAAG,GAAH,GAAG,CAAgB;IAAG,CAAC;IAEpC,IAAI,CAAC,IAAa;QACvB,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QACvD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACrC,CAAC;IAEM,IAAI,CAAC,IAAY;QACtB,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QAChD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAEM,IAAI,CAAC,IAAY;QACtB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import type { Route } from "../interface/route";
2
+ export declare class Router {
3
+ routes: Route[];
4
+ get(path: string, handler: Function): void;
5
+ put(path: string, handler: Function): void;
6
+ delete(path: string, handler: Function): void;
7
+ post(path: string, handler: Function): void;
8
+ }
9
+ //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/core/router.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,qBAAa,MAAM;IACV,MAAM,EAAE,KAAK,EAAE,CAAM;IAErB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ;IAQnC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ;IAQnC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ;IAQtC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ;CAO5C"}
@@ -0,0 +1,33 @@
1
+ import { Method } from "../enum/method";
2
+ export class Router {
3
+ routes = [];
4
+ get(path, handler) {
5
+ this.routes.push({
6
+ method: Method.GET,
7
+ path,
8
+ handler,
9
+ });
10
+ }
11
+ put(path, handler) {
12
+ this.routes.push({
13
+ method: Method.PUT,
14
+ path,
15
+ handler,
16
+ });
17
+ }
18
+ delete(path, handler) {
19
+ this.routes.push({
20
+ method: Method.DELETE,
21
+ path,
22
+ handler,
23
+ });
24
+ }
25
+ post(path, handler) {
26
+ this.routes.push({
27
+ method: Method.POST,
28
+ path,
29
+ handler,
30
+ });
31
+ }
32
+ }
33
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/core/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,MAAM,OAAO,MAAM;IACV,MAAM,GAAY,EAAE,CAAC;IAErB,GAAG,CAAC,IAAY,EAAE,OAAiB;QACxC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YACf,MAAM,EAAE,MAAM,CAAC,GAAG;YAClB,IAAI;YACJ,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IAEM,GAAG,CAAC,IAAY,EAAE,OAAiB;QACxC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YACf,MAAM,EAAE,MAAM,CAAC,GAAG;YAClB,IAAI;YACJ,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,IAAY,EAAE,OAAiB;QAC3C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YACf,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,IAAI;YACJ,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IAEM,IAAI,CAAC,IAAY,EAAE,OAAiB;QACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YACf,MAAM,EAAE,MAAM,CAAC,IAAI;YACnB,IAAI;YACJ,OAAO;SACR,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ export declare enum Method {
2
+ GET = "GET",
3
+ PUT = "PUT",
4
+ DELETE = "DELETE",
5
+ POST = "POST"
6
+ }
7
+ //# sourceMappingURL=method.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../../src/enum/method.ts"],"names":[],"mappings":"AAAA,oBAAY,MAAM;IACd,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,IAAI,SAAS;CAChB"}
@@ -0,0 +1,8 @@
1
+ export var Method;
2
+ (function (Method) {
3
+ Method["GET"] = "GET";
4
+ Method["PUT"] = "PUT";
5
+ Method["DELETE"] = "DELETE";
6
+ Method["POST"] = "POST";
7
+ })(Method || (Method = {}));
8
+ //# sourceMappingURL=method.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method.js","sourceRoot":"","sources":["../../src/enum/method.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,MAKX;AALD,WAAY,MAAM;IACd,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,2BAAiB,CAAA;IACjB,uBAAa,CAAA;AACjB,CAAC,EALW,MAAM,KAAN,MAAM,QAKjB"}
@@ -0,0 +1,2 @@
1
+ export * from './core';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './core';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { Method } from "../enum/method";
2
+ export interface Route {
3
+ method: Method;
4
+ path: string;
5
+ handler?: Function;
6
+ }
7
+ //# sourceMappingURL=route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/interface/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,MAAM,WAAW,KAAK;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,QAAQ,CAAA;CACrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../../src/interface/route.ts"],"names":[],"mappings":""}
package/dist/test.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":""}
package/dist/test.js ADDED
@@ -0,0 +1,21 @@
1
+ import { App } from "./core/app";
2
+ import { Controller, Get } from "./core/decorators";
3
+ const app = new App();
4
+ @Controller("/user")
5
+ class User {
6
+ @Get()
7
+ getAll() {
8
+ return JSON.stringify({
9
+ "id": 1,
10
+ "name": "jhon"
11
+ });
12
+ }
13
+ }
14
+ app.use(User);
15
+ app.get("/user2", (req, res) => {
16
+ res.send("Asi tambien se puede hacer la api!");
17
+ });
18
+ app.listen(3000, "localhost", () => {
19
+ console.log(":p");
20
+ });
21
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAIpD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;AAEtB,CAAC,UAAU,CAAC,OAAO,CAAC;MACd,IAAI;IACR,CAAC,GAAG,EAAE;IACN,MAAM;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC;YACpB,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC;CACF;AAED,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAEd,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE;IAChD,GAAG,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAA;AAChD,CAAC,CAAC,CAAA;AAEF,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE;IACjC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,18 +1,21 @@
1
1
  {
2
2
  "name": "@cleivermejia/backend",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "",
5
- "main": "index.js",
5
+ "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "test": "tsx watch src/test.ts",
8
- "dev": "tsx watch src/index.ts"
8
+ "dev": "tsx watch src/index.ts",
9
+ "clean": "npx rimraf dist",
10
+ "build": "npm run clean && tsc && tsc-alias"
9
11
  },
10
12
  "keywords": [],
11
13
  "author": "",
12
14
  "license": "ISC",
13
- "type": "commonjs",
15
+ "type": "module",
14
16
  "devDependencies": {
15
17
  "@types/node": "^25.9.2",
18
+ "tsc-alias": "^1.8.17",
16
19
  "typescript": "^6.0.3"
17
20
  }
18
21
  }
@@ -0,0 +1 @@
1
+ export * from './';
package/src/index.ts CHANGED
@@ -1,14 +1 @@
1
- import { App } from "./core/app";
2
- import type { Request } from "./core/request";
3
- import type { Response } from "./core/response";
4
-
5
- const app = new App();
6
- const PORT = 3000;
7
-
8
- app.get("/", (req: Request, res: Response) => {
9
- res.html('<h1>Hola mundo!</h1>');
10
- });
11
-
12
- app.listen(PORT, "localhost", () =>
13
- console.log(`Servidor encendido http://localhost:${PORT}`),
14
- );
1
+ export * from './core'
package/tsconfig.json CHANGED
@@ -2,11 +2,12 @@
2
2
  // Visit https://aka.ms/tsconfig to read more about this file
3
3
  "compilerOptions": {
4
4
  // File Layout
5
- // "rootDir": "./src",
6
- // "outDir": "./dist",
5
+ "rootDir": "./src",
6
+ "outDir": "./dist",
7
7
 
8
8
  // Environment Settings
9
9
  // See also https://aka.ms/tsconfig/module
10
+ "forceConsistentCasingInFileNames": true,
10
11
  "module": "esnext",
11
12
  "target": "esnext",
12
13
  // For nodejs: