Update configuration to get endpoint information

This commit is contained in:
2024-06-17 17:25:59 -04:00
parent 12c4aaa469
commit 735311eee4

View File

@@ -10,29 +10,18 @@ type Context = {
error: (msg: any) => void; error: (msg: any) => void;
}; };
export default async function ({req, res, log,error}: Context){ export default async function ({req, res, error}: Context){
// Output some info
log(req.bodyRaw); // Raw request body, contains request data
log(JSON.stringify(req.body)); // Object from parsed JSON request body, otherwise string
log(JSON.stringify(req.headers)); // String key-value pairs of all request headers, keys are lowercase
log(req.scheme); // Value of the x-forwarded-proto header, usually http or https
log(req.method); // Request method, such as GET, POST, PUT, DELETE, PATCH, etc.
log(req.url); // Full URL, for example: http://awesome.appwrite.io:8000/v1/hooks?limit=12&offset=50
log(req.host); // Hostname from the host header, such as awesome.appwrite.io
log(req.port); // Port from the host header, for example 8000
log(req.path); // Path part of URL, for example /v1/hooks
log(req.queryString); // Raw query params string. For example "limit=12&offset=50"
log(JSON.stringify(req.query)); // Parsed query params. For example, req.query.limit
const PROJECT_ID = Deno.env.get("APPWRITE_FUNCTION_PROJECT_ID") const PROJECT_ID = Deno.env.get("APPWRITE_FUNCTION_PROJECT_ID")
const API_KEY = Deno.env.get("APPWRITE_API_KEY") const API_KEY = Deno.env.get("APPWRITE_API_KEY")
if ( !PROJECT_ID || !API_KEY) { const API_ENDPOINT = Deno.env.get("APPWRITE_API_ENDPOINT")
if ( !PROJECT_ID || !API_KEY || !API_ENDPOINT) {
error('Environment not set'); error('Environment not set');
return {}; return {};
} }
const client = new Client() const client = new Client()
.setEndpoint('https://appwrite.oys.undock.ca/v1') .setEndpoint(API_ENDPOINT)
.setProject(PROJECT_ID) .setProject(PROJECT_ID)
.setKey(API_KEY) .setKey(API_KEY)