Rank 3: Container
Hi guys, i need an idea about it
I am creating document with appwrite functions for my project.
Note: I gave Users permission to this spesific function.
When i get POST request from client side, function is triggering and i am checking headers with
throwIfMissing(req.headers, ['x-appwrite-user-id', 'x-appwrite-user-jwt']);i want to create a document with permissions with the node-appwrite sdk.
But before i start,
My first question is that should i check jwt is valid or not?
// START: VERIFY USER WITH JWT try { const verifyUser = new Client() .setEndpoint(process.env.APP_ENDPOINT) .setProject(process.env.APP_PROJECT) .setJWT(req.headers['x-appwrite-user-jwt']);
const account = new Account(verifyUser); const user = await account.get(); log(`user: ${JSON.stringify(user)}`);
if (user.$id === req.headers['x-appwrite-user-id']) { log('jwt is valid'); } else { log('jwt is invalid'); return res.json({ ok: false, error: 'jwt is invalid' }, 400); } } catch (err) { log('jwt is invalid'); return res.json({ ok: false, error: err.message }, 400); } // END: VERIFY USER WITH JWTMy second question is that 10% of executions are going to end with Timeout What is the possible reasons for that?
I am creating 2 different client with jwt to check sender session is alive or not and the api key to give document based permissions.