find src/*
find src/* -not -path "src/dir-name-to-exclude/*"
import { Kysely, SqliteAdapter } from 'kysely' | |
export function KyselyAdapter(db: Kysely<any>): any { | |
const { adapter } = db.getExecutor() | |
const { supportsReturning } = adapter | |
const isSqlite = adapter instanceof SqliteAdapter | |
/** If the database is SQLite, turn dates into an ISO string */ | |
const to = isSqlite ? format.to : <T>(x: T) => x as T | |
/** If the database is SQLite, turn ISO strings into dates */ | |
const from = isSqlite ? format.from : <T>(x: T) => x as T |
version: '3.4' | |
services: | |
postgres: | |
container_name: postgres_api | |
image: postgres:16.3-alpine3.20 | |
ports: | |
- 5432:5432 | |
restart: always | |
volumes: | |
- db_data:/var/lib/postgresql/data |
{ | |
"scripts": { | |
// ... | |
"db:migrate:up": "bun run -r dotenv/config ./src/lib/db/migrate latest", | |
"db:migrate:down": "bun run -r dotenv/config ./src/lib/db/migrate down", | |
"db:migrate:create": "bun run -r dotenv/config ./src/lib/db/migrate create initial", | |
"db:generate:types": "bunx kysely-codegen --out-file=src/lib/db/schema/Database.ts", | |
}, | |
"dependencies": { | |
"kysely": "^0.27.3", |
[ | |
{ | |
"type": "alltrails", | |
"title": "Oeschinen Lake Lookout", | |
"movingTime": "1h 40m", | |
"length": "7.1 km", | |
"elevationGain": "386m", | |
"createdAt": "June 7, 2023", | |
"image": "http://alltrails.com/api/alltrails/v3/maps/175121895/profile_photo?size=large&key=3p0t5s6b5g4g0e8k3c1j3w7y5c3m4t8i&show_static_map=yes&static_map_size=396x180", | |
"url": "https://www.alltrails.com/explore/recording/afternoon-hike-at-oeschinenbahn-heuberg-db2b418" |
// zoneName: {country}/{city} | |
export const zoneTimeToUTC = ({ zoneName }) => { | |
const now = new Date('2022-12-06T20:12:46+10:00') | |
const nowTimezone = formatInTimeZone(now, zoneName, 'yyyy-MM-dd HH:mm:ss') | |
return zonedTimeToUtc(nowTimezone, zoneName).toISOString() | |
} |
[ | |
{ | |
"id": 1, | |
"name": "Jennifer Connelly" | |
}, | |
{ | |
"id": 2, | |
"name": "Tom Cruise", | |
"children": [ | |
{ |
#### Idea | |
- Structure a simple URL shortener. Simple URL and short URL | |
- Now, what if we want to manage a link for each user | |
- Ability to store views on the link | |
- Client is complaining that the link is slow | |
- Client is still complaining that the link is slow |
// DATA | |
// Initial JSON data | |
const people = [ | |
{ | |
id: 1, | |
name: 'Jennifer Connelly' | |
}, | |
{ | |
id: 2, | |
name: 'Tom Cruise', |
import hash from 'object-hash'; | |
import { createClient } from 'redis'; | |
import { config } from '../config'; | |
import { serialize } from '../utils/objectTransformer'; | |
import { log } from '../utils/errors'; | |
export const REDIS_KEY_PREFIX = `PROJECTPREFIX-${config.env?.toLowerCase()}`; | |
class RedisService { | |
client: any; |