-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DB and API Refactors #99
Changes from 4 commits
bd417e7
041a75a
2d30e2a
2f9eeb2
268618d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"scope": { | ||
"type": "http", | ||
"asgi": { | ||
"version": "3.0", | ||
"spec_version": "2.4" | ||
}, | ||
"http_version": "1.1", | ||
"server": ["127.0.0.1", 8000], // When running locally | ||
"client": ["127.0.0.1", 11563], // The port here changes dynamically | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a better way of handling this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If "this" refers to the "port changes dynamically" comment, then I don't know... To be honest, I don't even know why this port changes ... even though I've bounded Ansari frontend with port 3000 ... unless "client" here refers to something else, since origin does indeed have port 3000 ... |
||
"scheme": "http", | ||
"method": "POST", | ||
"root_path": "", | ||
"path": "/api/v2/users/login", | ||
"raw_path": "/api/v2/users/login", | ||
"query_string": "", | ||
"headers": [ | ||
["host", "localhost:8000"], | ||
["connection", "keep-alive"], | ||
["content-length", "83"], | ||
["sec-ch-ua-platform", "\"Windows\""], | ||
["user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"], | ||
["x-mobile-ansari", "ANSARI"], | ||
["sec-ch-ua", "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\""], | ||
["content-type", "application/json"], | ||
["sec-ch-ua-mobile", "?0"], | ||
["accept", "*/*"], | ||
["origin", "http://localhost:3000"], | ||
["sec-fetch-site", "same-site"], | ||
["sec-fetch-mode", "cors"], | ||
["sec-fetch-dest", "empty"], | ||
["referer", "http://localhost:3000/"], | ||
["accept-encoding", "gzip, deflate, br, zstd"], | ||
["accept-language", "en-GB,en;q=0.9,ar-EG;q=0.8,ar;q=0.7,en-US;q=0.6"] | ||
], | ||
"state": {}, | ||
"app": "<fastapi.applications.FastAPI object>", | ||
"starlette.exception_handlers": { | ||
"<class 'starlette.exceptions.HTTPException'>": "<function http_exception_handler>", | ||
"<class 'starlette.exceptions.WebSocketException'>": "<bound method ExceptionMiddleware.websocket_exception>", | ||
"<class 'fastapi.exceptions.RequestValidationError'>": "<function request_validation_exception_handler>", | ||
"<class 'fastapi.exceptions.WebSocketRequestValidationError'>": "<function websocket_request_validation_exception_handler>" | ||
}, | ||
"router": "<fastapi.routing.APIRouter object>", | ||
"endpoint": "<function login_user>", | ||
"path_params": {}, | ||
"route": { | ||
"path": "/api/v2/users/login", | ||
"name": "login_user", | ||
"methods": ["POST"] | ||
} | ||
}, | ||
"_receive": "<bound method RequestResponseCycle.receive>", | ||
"_send": "<function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender>", | ||
"_stream_consumed": true, | ||
"_is_disconnected": false, | ||
"_form": null, | ||
// _body's value (and other strings) were actually binary strings (i.e., start with b'...') | ||
"_body": "{\"email\":\"guest_<<AUTO_GENERATED_KEY>>@endeavorpal.com\",\"password\":\"<<PASSWORD_SENT_VIA_ANSARI_WEBSITE>>\",\"guest\":true}", | ||
// this is what actually gets returned when accessing headers property (e.g., `request.headers`) | ||
// Check Starlette's implementation (which FastAPI uses) for details: | ||
// https://github.com/encode/starlette/blob/b68a142a356ede730083347f254e1eae8b5c803e/starlette/requests.py#L12 | ||
"_headers": { | ||
"host": "localhost:8000", | ||
"connection": "...", | ||
"...": "..." | ||
// I.e., the value of the `_headers` key is a dictionary of the headers already mentioned above | ||
}, | ||
"_json": { | ||
"email": "guest_<<AUTO_GENERATED_KEY>>@endeavorpal.com", | ||
"...": ["..."] | ||
// I.e., the value of the `_json` key is simply the dictionary equivalent of `_body`'s string value | ||
}, | ||
"_query_params": "", | ||
"_cookies": {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
"scope": { | ||
"type": "http", | ||
"asgi": { | ||
"version": "3.0", | ||
"spec_version": "2.4" | ||
}, | ||
"http_version": "1.1", | ||
"server": ["127.0.0.1", 8000], // When running locally | ||
"client": ["<<WHATSAPP.USER.IP>>", 0], | ||
"scheme": "https", | ||
"method": "POST", | ||
"root_path": "", | ||
"path": "/whatsapp/v1", | ||
"raw_path": "/whatsapp/v1", | ||
"query_string": "", | ||
"headers": [ | ||
["host", "YOUR_ZROK_SHARE_TOKEN.share.zrok.io"], | ||
["user-agent", "facebookexternalua"], | ||
["content-length", "545"], | ||
["accept", "*/*"], | ||
["accept-encoding", "deflate, gzip"], | ||
["content-type", "application/json"], | ||
["x-amzn-trace-id", "Root=1-674b2035-0f0a8ab27075asce3324dcdb"], // trace value here is fake | ||
["x-forwarded-for", "173.REST.OF.IP, <<WHATSAPP.USER.IP>>"], | ||
["x-forwarded-port", "443"], | ||
["x-forwarded-proto", "https"], | ||
["x-hub-signature", "sha1=8a3e35da6fb5dfaaf5aaa46c8d059d519e18112d"], // sha1 hash here is fake | ||
["x-hub-signature-256", "sha256=51d62480d40ffd0f48d1cde1ea47656452fd65b5ac29077fe3c6b4e68d74c827"], // sha256 here is fake | ||
["x-proxy", "zrok"] | ||
], | ||
"state": {}, | ||
"app": "<FastAPI object>", | ||
"starlette.exception_handlers": { | ||
"<class 'starlette.exceptions.HTTPException'>": "<function http_exception_handler>", | ||
"<class 'starlette.exceptions.WebSocketException'>": "<bound method ExceptionMiddleware.websocket_exception>", | ||
"<class 'fastapi.exceptions.RequestValidationError'>": "<function request_validation_exception_handler>", | ||
"<class 'fastapi.exceptions.WebSocketRequestValidationError'>": "<function websocket_request_validation_exception_handler>" | ||
}, | ||
"router": "<APIRouter object>", | ||
"endpoint": "<function main_webhook>", | ||
"path_params": {}, | ||
"route": { | ||
"path": "/whatsapp/v1", | ||
"name": "main_webhook", | ||
"methods": ["POST"] | ||
} | ||
}, | ||
"_receive": "<bound method RequestResponseCycle.receive>", | ||
"_send": "<function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender>", | ||
"_stream_consumed": true, | ||
"_is_disconnected": false, | ||
"_form": null, | ||
"_query_params": "", | ||
// this is what actually gets returned when accessing headers property (e.g., `request.headers`) | ||
// Check Starlette's implementation (which FastAPI uses) for details: | ||
// https://github.com/encode/starlette/blob/b68a142a356ede730083347f254e1eae8b5c803e/starlette/requests.py#L125 | ||
"_headers": { | ||
"host": "...", | ||
"user-agent": "...", | ||
"...": "..." | ||
// I.e., the value of the `_headers` key is a dictionary of the headers already mentioned above | ||
}, | ||
"_cookies": {}, | ||
// _body's value (and other strings) were actually binary strings (i.e., start with b'...') | ||
// Also, it contains content mentioned in other `meta_whatsapp_*.json` files | ||
"_body": "{\"object\":\"whatsapp_business_account\", ...}", | ||
"_json": { | ||
"object": "whatsapp_business_account", | ||
"...": ["..."] | ||
// I.e., the value of the `_json` key is simply the dictionary equivalent of `_body`'s string value | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the extensive comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I was thinking of other ways to document these comments externally, but until we figure something out, will stick to inline commenting as I do think these should help newcomers .