This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn process_response(response) { | |
| response.headers["set-cookie"] = "foo=bar; Domain=localhost; Path=/; Expires=Wed, 04 Jan 2023 17:25:27 GMT; HttpOnly; Secure; SameSite=None"; | |
| // This overwrites the first header set above | |
| response.headers["set-cookie"] = "foo2=bar2; Domain=localhost; Path=/; Expires=Wed, 04 Jan 2023 17:25:27 GMT; HttpOnly; Secure; SameSite=None"; | |
| // This does not work | |
| response.headers["set-cookie"] = [ | |
| "foo=bar; Domain=localhost; Path=/; Expires=Wed, 04 Jan 2023 17:25:27 GMT; HttpOnly; Secure; SameSite=None", | |
| "foo2=bar2; Domain=localhost; Path=/; Expires=Wed, 04 Jan 2023 17:25:27 GMT; HttpOnly; Secure; SameSite=None", | |
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| id | data | |
|---|---|---|
| 1 | 0x2550 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Redis from 'ioredis'; | |
| const requiresTLS = process.env.NODE_ENV === 'production'; | |
| const client = new Redis({ | |
| host: process.env.REDIS_HOST as string, | |
| password: process.env.REDIS_PASSWORD as string, | |
| port: parseInt(process.env.REDIS_PORT, 10), | |
| // {} prop enables TLS (typical for production, not while developing locally) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Source: https://github.com/prisma/prisma/issues/2443#issuecomment-630679118 | |
| * Client typings is generated with the cli commands below: | |
| * | |
| * prisma generate --schema prisma/schema1.prisma | |
| * prisma generate --schema prisma/schema2.prisma | |
| */ | |
| import { PrismaClient as PrismaClient1 } from '../prisma/client1' | |
| import { PrismaClient as PrismaClient2 } from '../prisma/client2' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { Meta } from '@storybook/react'; | |
| import Component from './ImageIcon'; | |
| export default { | |
| title: 'components/ImageIcon/ImageIcon', | |
| component: Component, | |
| } as Meta; | |
| const Template = (props: React.ComponentProps<typeof Component>) => <Component {...props} />; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ICache } from './types'; | |
| import { MemoryClient } from './memoryClient'; | |
| import { RedisClient } from './redisClient'; | |
| export class CacheClient implements ICache { | |
| private client: ICache; | |
| constructor({ redisUrl }: { redisUrl?: string }) { | |
| if (redisUrl) { | |
| this.client = new RedisClient({ redisUrl }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Demo of creating upload urls to AWS S3. | |
| // See github.com/tomfa/nextjs-s3-upload for a complete app | |
| import { | |
| S3Client, | |
| PutObjectCommand, | |
| } from "@aws-sdk/client-s3"; | |
| import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; | |
| const s3 = new S3Client({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type ApplicationLog = { | |
| level: 'debug' | 'info' | 'warning' | 'danger' | 'critical', | |
| message: string, | |
| createdAt: number, | |
| userId?: string, | |
| // a business metric, e.g. SIGNUP | |
| action?: string, | |
| monetaryValue?: number, | |
| requestId?: string, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 1. install dependencies | |
| # 2. Set service account json in code | |
| # or with env var "SA_ACCOUNT" | |
| # 3. Run this file to import test data: | |
| # "python3 bigquery_import.py" | |
| import os | |
| import json | |
| from google.cloud import bigquery |