Skip to content

Instantly share code, notes, and snippets.

View r1tsuu's full-sized avatar
🚩

Ritsu r1tsuu

🚩
View GitHub Profile
@r1tsuu
r1tsuu / next.config.mjs
Last active July 1, 2024 00:34
Patch next with PR adds experimental serverOnlyDependencies property https://github.com/vercel/next.js/pull/65415
import { withPayload } from '@payloadcms/next/withPayload';
import { resolve } from 'path';
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverOnlyDependencies: [resolve(import.meta.dirname, 'payload.config.proxy.ts')],
},
};
@r1tsuu
r1tsuu / config.ts
Created May 11, 2024 01:26
Community Payload 3.0 test config for Postgres with 2kk docs
import { randomBytes } from 'crypto'
import { sql } from 'drizzle-orm'
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
import { devUser } from '../credentials.js'
import { PostsCollection } from './collections/Posts/index.js'
import { MenuGlobal } from './globals/Menu/index.js'
export const chunkArray = <T>(array: T[], length: number): T[][] => {
return Array.from({ length: Math.ceil(array.length / length) }, (_, i) =>
@r1tsuu
r1tsuu / docker-compose.yml
Created May 7, 2024 22:46
docker-compose.yml
version: "3.9"
services:
postgres:
image: postgres:14-alpine
restart: unless-stopped
ports:
- 5432:5432
volumes:
- data:/var/lib/postgresql/data
@r1tsuu
r1tsuu / bump-payload.ts
Last active May 4, 2024 21:03
script to bump all Payload 3.0 related packages versions to latest.
/**
* Place this to ./src/scripts/bump-payload.ts
* Then in your package.json add script:
* "bump-payload": "tsx ./src/scripts/bump-payload.ts ./package.json && pnpm i"
* Run `pnpm bump-payload`
*/
import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';
@r1tsuu
r1tsuu / _index.ts
Last active April 23, 2024 11:06
Payload 3.0 REST client with generated types
/* eslint-disable require-await */
import type { BulkOperationResult } from 'node_modules/payload/dist/collections/config/types';
import type { PaginatedDocs } from 'payload/database';
import type { Where } from 'payload/types';
import type { Config } from 'payload-types';
import type { DeepPartial } from 'ts-essentials';
import type { APIBuilderArgs } from './types';
import { buildQueryString } from './buildQueryString';
@r1tsuu
r1tsuu / pluginCollectionsDocsSetup.ts
Created March 6, 2024 23:13
Plugin collections docs order setup for existed collections.
import dotenv from 'dotenv';
import path from 'path';
import payload from 'payload';
dotenv.config({
path: path.resolve(__dirname, '../.env'),
});
const collections = [
'products',
@r1tsuu
r1tsuu / example.ts
Last active September 5, 2023 06:45
Find handler with sort by multiple params
// Usage example
// http://localhost:3000/api/example?sort[title]=1&sort[createdAt]=1
// or with qs.stringify({sort: {title: 1, createadAt: 1} })
const Pages: CollectionConfig = {
/// ...,
endpoints: [
{
path: '/',
handler: findHandler,