bind q forward;sprint
bind z attack;duck
bind z +attack;+duck
| import { type SignOptions, type VerifyOptions, sign, verify } from 'jsonwebtoken'; | |
| import { z } from 'zod'; | |
| import { config } from '#infrastructure/config/config.js'; | |
| export const jwt = { | |
| sign: <T extends object>(payload: T, options?: SignOptions) => | |
| sign(payload, config.jwt.privateKey, { | |
| algorithm: 'RS512', | |
| ...options, |
| import { createCipheriv, createDecipheriv, privateDecrypt, publicEncrypt, randomBytes } from 'node:crypto'; | |
| import { config } from '#infrastructure/config/config.js'; | |
| export const encryption = { | |
| encrypt: (buffer: Buffer) => { | |
| const key = randomBytes(32); | |
| const iv = randomBytes(16); | |
| const cipher = createCipheriv('aes-256-cbc', key, iv); | |
| const encryptedKey = publicEncrypt(config.encryption.publicKey, key); |
| export const AuthProvider: FunctionComponent<AuthProviderProps> = (props) => { | |
| const { children } = props; | |
| const [token, setToken] = useLocalStorage<string | null>({ | |
| key: 'auth.token', | |
| defaultValue: null, | |
| getInitialValueInEffect: true, | |
| }); | |
| const [user, setUser] = useLocalStorage<UsersMeResponse | null>({ |
| const simulateSlowHttpRequest = async (dummyData: string): Promise<string> => | |
| new Promise<string>((resolve) => setTimeout(() => resolve(dummyData), 2000)); | |
| const bootstrap = async (): Promise<void> => { | |
| /** | |
| * Test A | |
| */ | |
| const startA = Date.now(); | |
| const aA = await simulateSlowHttpRequest('a'); |
| // modules/example/interfaces/listing.interface.ts | |
| export interface ListingInterface { | |
| names: string[]; | |
| } | |
| // modules/example/dtos/listing.dto.ts | |
| export class ListingPayloadDto implements ListingInterface { | |
| // class-validator validations | |
| // @nestjs/swagger decorators | |
| readonly names!: string[]; |
| { | |
| "products": [ | |
| { | |
| "uuid": "bd24626d-a078-403d-ae5e-6df5d9690908", | |
| "name": "Minecraft Server (Modded)" | |
| }, | |
| { | |
| "uuid": "d8721919-a652-462b-95ac-b276db1412fb", | |
| "name": "WordPress" | |
| }, |
| import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common'; | |
| import { PrismaClient } from '@prisma/client'; | |
| import knex from 'knex'; | |
| import knexfile from './knexfile'; | |
| @Injectable() | |
| export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy { | |
| /** | |
| * Waits for the database to be available. | |
| */ |
| const bootstrap = async (): Promise<void> => { | |
| // Do stuff | |
| }); | |
| bootstrap().catch((error: Error) => { | |
| // Send error to sentry or Slack | |
| console.error(error); | |
| }); |
| #!/bin/bash | |
| WORKSPACE=$1 | |
| log() { | |
| echo "[$(date +"%D %T")] $1" >> "$WORKSPACE/deployment.log" | |
| echo $1 | |
| } | |
| # Check if the workspace directory exists |