INNER CODE UNIT · TypeScript

api

aws-devtools-labs/aws-blocks · native/swift/Demo/typescript-demo/aws-blocks/index.ts:88

export const api = new ApiNamespace(scope, 'api', (context) => ({
  async getValue(key: string) {
    return await store.get(key);
  },
  
  async setValue(key: string, value: string) {
    await store.put(key, value);
    return { success: true };
  },
  
  async setCookie(name: string, value: string) {
    context.response.headers.set('set-cookie', `${name}=${value}; Max-Age=3600; Secure; SameSite=None; Partitioned`);
    return { success: true };
  },
  
  async getCookie(name: string) {
    const cookies = context.request.headers.get('cookie') || '';
    const match = cookies.split('; ').find(c => c.startsWith(`${name}=`));

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…