haxetink / tink_web

Tinkerbell Web Framework
https://haxetink.github.io/tink_web
43 stars 14 forks source link

Add remote proxying. Fix incorrect type in macro #128

Closed piboistudios closed 2 years ago

piboistudios commented 2 years ago

This will allow you to return tink.web.proxy.Remote instances from routes like so:

    @:sub("/@me")
    @:async public function me(user:Session.User):tink.web.proxy.Remote<UserProxy> {
        return duckProxy.users(AppSettings.config.wildDuck.apiKey).get(user.duck.id);
    }

Then, using this remote interface as an example:

GET /api/@me/mailboxes/61cbf39ac3b56500072d77d8/messages/18 HTTP/1.1
Host: localhost:3000
Content-Type: application/json
x-access-token: <access-token>
{
    "username": "<username>",
    "password": "<password>"
}------WebKitFormBoundary7MA4YWxkTrZu0gW--

Response:

{
    "answered": false,
    "attachments": [],
    "contentType": {
        "params": {
            "boundary": "000000000000df2f8705d53e1902"
        },
        "value": "multipart/alternative"
    },
    "date": "2022-01-10T17:59:31.000Z",
    "deleted": false,
    "draft": false,
    "envelope": {
        "from": "gabriel.speed.bullock@gmail.com",
        "rcpt": [
            {
                "formatted": "webmaster@gabedev.tech",
                "value": "webmaster@gabedev.tech"
            }
        ]
    },
    "flagged": false,
    "forwarded": false,
    "from": {
        "address": "gabriel.speed.bullock@gmail.com",
        "name": "Gabriel Speed"
    },
    "html": [
        "<div dir=\"auto\">You made the Protoverse, Usernet, GunChain and Boisly</div>"
    ],
    "id": 18,
    "mailbox": "61cbf39ac3b56500072d77d8",
    "messageId": "<CAFoxTFqQo5XsNbX-6QA+X+60TWY0CY7f5p4+ZUYtcHbuz3+R4Q@mail.gmail.com>",
    "metaData": {},
    "seen": false,
    "size": 3565,
    "subject": "Protoverse",
    "success": true,
    "text": "You made the Protoverse, Usernet, GunChain and Boisly",
    "thread": "61dc740fe9e4e70012b37833",
    "to": [
        {
            "address": "gabe4haxelang@gmail.com",
            "name": ""
        },
        {
            "address": "webmaster@gabedev.tech",
            "name": ""
        }
    ],
    "user": "61cbf39ac3b56500072d77d7",
    "verificationResults": {
        "dkim": "gmail.com",
        "spf": "gmail.com",
        "tls": {
            "name": "TLS_AES_256_GCM_SHA384",
            "version": "TLSv1.3"
        }
    }
}
back2dos commented 2 years ago

Any idea what's going on with the disabled test? Otherwise, I'll try to check it this weekend ;)

piboistudios commented 2 years ago

Any idea what's going on with the disabled test? Otherwise, I'll try to check it this weekend ;)

Not really. I had to make it dynamic, and also scheme is actually undefined (or null in Haxe) and not '' as the test case was expecting..

piboistudios commented 2 years ago

Any idea what's going on with the disabled test? Otherwise, I'll try to check it this weekend ;)

Not really. I had to make it dynamic, and also scheme is actually undefined (or null in Haxe) and not '' as the test case was expecting..

And yet the test now fails... I am not sure. Probably because I use haxelib PM vs lix PM

grepsuzette commented 2 years ago

kind of like a symlink for APIs? I really like it

kevinresol commented 2 years ago

or can you just leave the issue123 test unchanged? we can deal with it in another issue if it is still a problem

kevinresol commented 2 years ago

or can you just leave the issue123 test unchanged? we can deal with it in another issue if it is still a problem

Can you do it in a way such that it shows no changes in this PR?

piboistudios commented 2 years ago

or can you just leave the issue123 test unchanged? we can deal with it in another issue if it is still a problem

Can you do it in a way such that it shows no changes in this PR?

Yeah, I am not really sure how to do that without opening another PR

kevinresol commented 2 years ago

Keep committing until the changes disappear in the "Changes" tab in this PR

piboistudios commented 2 years ago

Yeah, probably instead I just won't make anymore pull requests :). Make it yourself.

It was a simple enough change.