How can I choose node-18 runtime when using appwrite-cli to init function? My appwrite-cli only display this: I'm use latest docker version of appwrite: appwrite/appwrite:1.2.1
Node.js (node-16.0)
PHP (php-8.0)
Ruby (ruby-3.0)
Python (python-3.9)
appwrite -v
1.2.1
Can not see node-18 runtime when init function using appwrite-cli
This might help you: https://github.com/appwrite/appwrite/discussions/4826
I deploy my first function but get time out. My code is try to verify purchase using googleapi. This code work fine in my local node server. How can I inspect to fix this error
What's your full code?
const {GoogleAuth} = require("google-auth-library");
const {androidpublisher_v3} =require("googleapis");
const credentials = require("./assets/service-account.json");
const {ANDROID_PACKAGE_ID, productDataMap} = require("./constants");
const handleSubscription = async(
productData,
token,
) => {
var androidPublisher = new androidpublisher_v3.Androidpublisher({
auth: new GoogleAuth(
{
credentials,
scopes: ["https://www.googleapis.com/auth/androidpublisher"],
}),
});
let response;
try {
response = await androidPublisher.purchases.subscriptions.get(
{
packageName: ANDROID_PACKAGE_ID,
subscriptionId: productData.productId,
token,
},
);
} catch (err){
throw err;
}
// Make sure an order id exists
if (!response.data.orderId) {
return false;
}
// If a subscription suffix is present (..#) extract the orderId.
let orderId = response.data.orderId;
const orderIdMatch = /^(.+)?[.]{2}[0-9]+$/g.exec(orderId);
if (orderIdMatch) {
orderId = orderIdMatch[1];
}
console.log({
rawOrderId: response.data.orderId,
newOrderId: orderId,
});
// Construct purchase data for db updates
const purchaseData = {
type: "SUBSCRIPTION",
iapSource: "google_play",
orderId: orderId,
productId: productData.productId,
purchaseDate: response.data.startTimeMillis ?? 0,
expiryDate: response.data.expiryTimeMillis ?? 0,
status: [
"PENDING", // Payment pending
"ACTIVE", // Payment received
"ACTIVE", // Free trial
"PENDING", // Pending deferred upgrade/downgrade
"EXPIRED", // Expired or cancelled
][response.data.paymentState ?? 4],
};
return purchaseData;
}
module.exports = async function (req, res) {
// const payload = JSON.parse(req.payload);
// if (!payload.productId || !payload.token){
// console.log("No payload");
// res.json({status: '1'});
// }
const productData = productDataMap["soundwave_pro"];
// if (!productData) {
// console.log("No productData");
// res.json({status: '2'});
// }
const data = await handleSubscription(productData,"thisisfixedtoken");
if (!data){
res.json({status: '3'});
}
};
My project structure
How can I check why this code timeout
You should make sure you're calling res.json() exactly once. It seems like it's possible for you to not based on this code.
Although connection refused is an even bigger problem ..it might mean the runtime container isn't working at all. Maybe syntax problem or something.
This code from codelabs tutorial and I run successful in local node server
Regardless, something might be wrong in the runtime. I would recommend recreating your function from scratch adding bits slowly, starting with the imports
Thank you for help
Recommended threads
- I can't UNPAUSE my project with the free...
I received an email notifying me that my project had been paused due to inactivity, and the email included a link to "Restore project." However, that button red...
- Error trying to deploy functions from CL...
✗ Error • on-auth-create (6a00b2ab000c9ce2949b) • Server Error ✗ Error: No functions were pushed. Prject ID: 69ffe0270033a4ac420a
- Intermittent Deploy and Execution Errors...
Project: project-fra-658e2f5f4ba30df91177 Function ID: 69bde006001c56757f49 **Several execution errors with:** Timed out waiting for runtime.\nError Code: 400...