framework-do-dede 0.0.14 → 0.0.16

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,4 +1,4 @@
1
- import { Inject } from '@/decorators';
1
+ import { Inject } from '../decorators';
2
2
  import 'reflect-metadata';
3
3
  class ComponentRegistry {
4
4
  static instance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "framework-do-dede",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
package/dist/example.d.ts DELETED
File without changes
package/dist/example.js DELETED
@@ -1,102 +0,0 @@
1
- "use strict";
2
- // import { Auth, Controller, Get, Inject, Middleware, Post, Validator } from "@/decorators";
3
- // import ControllerHandler from "@/handlers/controller.handler";
4
- // import { UseCaseHandler } from "@/handlers/usecase.handler";
5
- // import HttpServer from "@/http/HttpServer";
6
- // import { BadRequest } from "@/http/ServerError";
7
- // import type { HttpMiddleware } from "@/protocols/HttpMiddleware";
8
- // import type { UseCase } from "@/protocols/UseCase";
9
- // import { Registry } from "@/di/registry";
10
- // import Elysia from "elysia";
11
- // import type { Validation } from "@/protocols";
12
- // Registry.register('controllers', []);
13
- // class ValidateUser implements Validation {
14
- // validate(input: any) {
15
- // if (!input.name) {
16
- // throw new BadRequest('name is required')
17
- // }
18
- // return input
19
- // }
20
- // }
21
- // class UserAuth implements HttpMiddleware {
22
- // async execute(input: any) {
23
- // return {
24
- // auth: true
25
- // }
26
- // }
27
- // }
28
- // class Test implements HttpMiddleware {
29
- // async execute(input: any) {
30
- // return {
31
- // test: true
32
- // }
33
- // }
34
- // }
35
- // type Input = { name: string, age: number, email: string, password: string };
36
- // type Output = void;
37
- // interface UserRepository {
38
- // create: (input: any) => Promise<void>
39
- // }
40
- // class UserRepositoryDatabase implements UserRepository {
41
- // async create(data: any): Promise<void> {
42
- // console.log('creating user', data)
43
- // }
44
- // }
45
- // Registry.register('UserRepository', Registry.classLoader(UserRepositoryDatabase))
46
- // class CreateUser implements UseCase<Input, Output> {
47
- // @Auth()
48
- // private auth: any;
49
- // constructor(
50
- // @Inject('UserRepository')
51
- // private readonly userRepository: UserRepository
52
- // ) {}
53
- // async execute(input: Input): Promise<Output> {
54
- // this.userRepository.create(input)
55
- // }
56
- // }
57
- // class GetUser implements UseCase<Input, Output> {
58
- // @Auth()
59
- // private auth!: boolean
60
- // constructor(
61
- // @Inject('UserRepository')
62
- // private readonly userRepository: UserRepository
63
- // ) {}
64
- // async execute(input: Input): Promise<Output> {
65
- // console.log(' testing', this.auth)
66
- // await this.userRepository.create(input)
67
- // }
68
- // }
69
- // type RequestData = {
70
- // headers: any,
71
- // data: any,
72
- // middlewareData: any
73
- // }
74
- // @Controller('/users')
75
- // class UserController {
76
- // @Post({ statusCode: 201 })
77
- // @Validator(ValidateUser)
78
- // @Middleware(UserAuth)
79
- // // @Middleware(Test)
80
- // createUser(input: any, request: RequestData) {
81
- // console.log('request', request)
82
- // return UseCaseHandler.load(CreateUser, request).execute(input)
83
- // }
84
- // @Get({ query: ['time|string'], statusCode: 200 })
85
- // @Middleware(UserAuth)
86
- // // @Middleware(Test)
87
- // getUser(input: any, request: RequestData) {
88
- // console.log('middlewareData', request.middlewareData)
89
- // return UseCaseHandler.load(GetUser, request).execute(input)
90
- // }
91
- // }
92
- // class ExpressHttpServer extends HttpServer {
93
- // constructor() {
94
- // super(new Elysia(), 'elysia')
95
- // }
96
- // listen(port: number): void {
97
- // super.listen(port)
98
- // console.log(`Server listening on port ${port}`)
99
- // }
100
- // }
101
- // const server = new ExpressHttpServer()
102
- // new ControllerHandler(server, 3000)
@@ -1,5 +0,0 @@
1
- import { UseCase } from "@/protocols";
2
- import { RequestData } from "..";
3
- export declare class UseCaseHandler {
4
- static load<T extends UseCase<any, any>>(useCaseClass: new (...args: any[]) => T, request?: RequestData): T;
5
- }
@@ -1,12 +0,0 @@
1
- import { Registry } from "@/di/registry";
2
- export class UseCaseHandler {
3
- static load(useCaseClass, request) {
4
- const instance = Registry.classLoader(useCaseClass);
5
- const auth = Reflect.getMetadata("auth", useCaseClass);
6
- const context = request;
7
- if (auth && context?.middlewareData) {
8
- instance[auth] = context.middlewareData[auth];
9
- }
10
- return instance;
11
- }
12
- }