Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,8 @@ updates:
default-days: 1
versioning-strategy: increase
groups:
uncheck:
patterns:
- uncheck
- oxlint
- oxfmt
dev-dependencies-minor-patch:
dependency-type: development
exclude-patterns:
- uncheck
- oxlint
- oxfmt
update-types:
- minor
- patch
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
!.vscode/
!.github/
!.zed/
!.agents/
!.claude/
.claude/worktrees/

# Common generated folders
logs/
Expand Down
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["oxc.oxc-vscode"]
}
3 changes: 0 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
// Format with oxfmt on save, needs the oxc.oxc-vscode extension
"editor.defaultFormatter": "oxc.oxc-vscode",
"editor.formatOnSave": true,

// Apply oxlint's auto fixes on save
"editor.codeActionsOnSave": {
"source.fixAll.oxc": "explicit"
}
Expand Down
11 changes: 1 addition & 10 deletions .zed/settings.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{
"format_on_save": "on",
"formatter": {
"external": {
"command": "./node_modules/.bin/oxfmt",
"arguments": ["--stdin-filepath", "{buffer_path}"]
}
},
// Apply oxlint's auto fixes on save:
"code_actions_on_format": {
"source.fixAll.oxc": true
}
"formatter": [{ "code_action": "source.fixAll.oxc" }, { "language_server": { "name": "oxfmt" } }]
}
30 changes: 30 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# AGENTS.md

## Repository

Standard Server: transport-agnostic request and response adapters, in a pnpm monorepo.

- `packages/*`: the published packages
- `tests/`: e2e tests; `tests/bun` runs with `bun test`
- `playgrounds/*`: example apps
- `benches/`: benchmarks

## Commands

```bash
pnpm install
pnpm test # bun tests + vitest
pnpm vitest run <path> # one test file
pnpm check # lint and type check, including *.test-d.ts
pnpm fix # check, applying fixes
pnpm format # format with oxfmt
pnpm repo:fix # fix monorepo issues (sherif)
pnpm bench
pnpm --filter @standard-server/core prepack # build one package; tests don't need a build
```

Before finishing, run `pnpm format`, `pnpm check` and `pnpm test`. CI doesn't check formatting.

## Pull requests

Titles follow Conventional Commits, scoped by the affected packages, separated by a comma and a space: `fix(node): ...`, `fix(node, fastify): ...`. Leave out the scope when the change is too broad.
2 changes: 1 addition & 1 deletion benches/__shared__/client-server.fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
toStandardLazyResponse,
} from '@standard-server/fetch'

import type { ClientServer } from './client-server'
import type { ClientServer } from './client-server.ts'

export function createFetchClientServer(): ClientServer {
const clientServer: ClientServer = {
Expand Down
2 changes: 1 addition & 1 deletion benches/__shared__/client-server.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { AddressInfo } from 'node:net'
import { toFetchBody, toFetchHeaders, toStandardLazyResponse } from '@standard-server/fetch'
import { sendStandardResponse, toStandardLazyRequest } from '@standard-server/node'

import type { ClientServer } from './client-server'
import type { ClientServer } from './client-server.ts'

export function createNodeClientServer(): ClientServer {
const clientServer: ClientServer = {
Expand Down
6 changes: 3 additions & 3 deletions benches/__shared__/client-server.peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ServerPeer,
} from '@standard-server/peer'

import type { ClientServer } from './client-server'
import type { ClientServer } from './client-server.ts'

export function createPeerClientServer(): ClientServer {
const clientServer: ClientServer = {
Expand All @@ -25,7 +25,7 @@ export function createPeerClientServer(): ClientServer {
return
}

clientPeer.message(decoded.message)
void clientPeer.message(decoded.message)
})

const clientPeer = new ClientPeer(async (message) => {
Expand All @@ -36,7 +36,7 @@ export function createPeerClientServer(): ClientServer {
throw new Error('not found')
}

serverPeer.message(decoded.message, clientServer.handler)
void serverPeer.message(decoded.message, clientServer.handler)
})

return clientServer
Expand Down
12 changes: 6 additions & 6 deletions benches/__shared__/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function createUnit(i: number) {

/** Pad a JSON value so `stringifyJSON` length equals `size`. */
function padJson(value: object, size: number): object {
const base = stringifyJSON({ ...value, _pad: '' })!.length
const base = stringifyJSON({ ...value, _pad: '' }).length
if (base > size) throw new Error(`json core ${base} > ${size}`)
return { ...value, _pad: 'x'.repeat(size - base) }
}
Expand All @@ -35,14 +35,14 @@ export const JSON_10KB = padJson(
)

function splitBytes(size: number, parts: number): Uint8Array<ArrayBuffer>[] {
const buf = new Uint8Array(size) as Uint8Array<ArrayBuffer>
const buf = new Uint8Array(size)
const base = Math.floor(size / parts)
let rem = size - base * parts
const out: Uint8Array<ArrayBuffer>[] = []
let off = 0
for (let i = 0; i < parts; i++) {
const n = base + (rem-- > 0 ? 1 : 0)
out.push(buf.subarray(off, off + n) as Uint8Array<ArrayBuffer>)
out.push(buf.subarray(off, off + n))
off += n
}
return out
Expand All @@ -62,7 +62,7 @@ function formContentSize(form: FormData): number {
export const FORM_10KB = new FormData()
FORM_10KB.append('userId', 'user_0')
FORM_10KB.append('action', 'create')
FORM_10KB.append('meta', stringifyJSON({ tags: ['a', 'b'], dryRun: false })!)
FORM_10KB.append('meta', stringifyJSON({ tags: ['a', 'b'], dryRun: false }))
FORM_10KB.append('note', 'hello world')
{
const fileSize = SIZE_10KB - formContentSize(FORM_10KB)
Expand Down Expand Up @@ -90,8 +90,8 @@ export const USP_10KB = new URLSearchParams({
/** Events totaling 10KB of stringified JSON. */
function makeEvents(size: number): object[] {
const parts: object[] = [PAYLOAD_UNIT, PAYLOAD_UNIT, PAYLOAD_UNIT, { type: 'pad', text: '' }]
const core = parts.slice(0, -1).reduce((n, p) => n + stringifyJSON(p)!.length, 0)
const padBase = stringifyJSON({ type: 'pad', text: '' })!.length
const core = parts.slice(0, -1).reduce((n, p) => n + stringifyJSON(p).length, 0)
const padBase = stringifyJSON({ type: 'pad', text: '' }).length
if (core + padBase > size) throw new Error(`event core ${core + padBase} > ${size}`)
parts[parts.length - 1] = { type: 'pad', text: 'x'.repeat(size - core - padBase) }
return parts
Expand Down
10 changes: 5 additions & 5 deletions benches/e2e.bench.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { bench, describe } from 'vitest'

import { echoHandler, roundTrip } from './__shared__/client-server'
import { createFetchClientServer } from './__shared__/client-server.fetch'
import { createNodeClientServer } from './__shared__/client-server.node'
import { createPeerClientServer } from './__shared__/client-server.peer'
import { createFetchClientServer } from './__shared__/client-server.fetch.ts'
import { createNodeClientServer } from './__shared__/client-server.node.ts'
import { createPeerClientServer } from './__shared__/client-server.peer.ts'
import { echoHandler, roundTrip } from './__shared__/client-server.ts'
import {
asAsyncIteratorObject,
asReadableStream,
Expand All @@ -13,7 +13,7 @@ import {
FORM_10KB,
JSON_10KB,
USP_10KB,
} from './__shared__/payloads'
} from './__shared__/payloads.ts'

const adapters = [
['node-adapter', createNodeClientServer],
Expand Down
7 changes: 5 additions & 2 deletions oxfmt.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { defineConfig } from 'oxfmt'
import { middleapi } from 'uncheck/oxfmt'

export default defineConfig({
...middleapi,
ignorePatterns: ['.agents/skills/**', '.claude/skills/**'],
semi: false,
singleQuote: true,
quoteProps: 'consistent',
sortImports: true,
})
37 changes: 26 additions & 11 deletions oxlint.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
import { defineConfig } from 'oxlint'
import { middleapi } from 'uncheck/oxlint'

export default defineConfig({
extends: [middleapi],
ignorePatterns: ['.agents/skills/**', '.claude/skills/**'],
options: {
typeAware: true,
typeCheck: true,
},
categories: {
correctness: 'error',
suspicious: 'error',
},
plugins: ['eslint', 'typescript', 'unicorn', 'oxc', 'import'],
rules: {
'typescript/no-unsafe-type-assertion': 'off',
'no-underscore-dangle': 'off',

'eqeqeq': 'error',
'guard-for-in': 'error',
'no-prototype-builtins': 'error',
'no-throw-literal': 'error',
'prefer-promise-reject-errors': 'error',
'no-console': ['error', { allow: ['warn', 'error'] }],
'no-var': 'error',
'prefer-const': 'error',
'typescript/no-import-type-side-effects': 'error',
'unicorn/prefer-node-protocol': 'error',
'no-restricted-properties': [
'error',
{
Expand Down Expand Up @@ -43,19 +64,13 @@ export default defineConfig({
},
},
{
files: [
'**/*.test.ts',
'**/*.test.tsx',
'**/*.test-d.ts',
'**/*.test-d.tsx',
'playgrounds/**',
'packages/*/playground/**',
],
files: ['**/*.test.ts', '**/*.test-d.ts', 'playgrounds/**'],
rules: {
'no-unused-vars': 'off',
'no-restricted-properties': 'off',
'no-restricted-globals': 'off',
'no-console': 'off',
'no-shadow': 'off',
'unicorn/consistent-function-scoping': 'off',
},
},
],
Expand Down
26 changes: 10 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
"license": "MIT",
"type": "module",
"scripts": {
"prepare": "uncheck prepare --pre-commit",
"check": "uncheck",
"fix": "uncheck --fix",
"check": "oxlint",
"fix": "oxlint --fix",
"format": "oxfmt",
"repo:fix": "sherif --fix",
"test": "pnpm run -r test && vitest run",
"test:coverage": "pnpm run -r test && vitest run --coverage",
"bench": "vitest bench --run",
"sponsors:sync": "node scripts/sync-sponsors.ts && pnpm run fix '**/README.md'"
"sponsors:sync": "node scripts/sync-sponsors.ts && oxfmt '**/README.md'"
},
"devDependencies": {
"@codspeed/vitest-plugin": "^5.7.1",
Expand All @@ -34,23 +35,16 @@
"express4": "npm:express@^4.22.3",
"fastify": "^5.12.5",
"h3": "2.0.2",
"oxfmt": "^0.72.0",
"oxlint": "^1.87.0",
"oxfmt": "^0.76.0",
"oxlint": "^1.91.0",
"oxlint-tsgolint": "^7.0.2005",
"pkg-pr-new": "^0.0.91",
"selfsigned": "^5.5.0",
"sherif": "^1.13.0",
"srvx": "^1.0.5",
"typescript": "^6.0.3",
"unbuild": "^3.6.1",
"uncheck": "^0.1.1",
"typescript": "^7.0.2",
"vitest": "^4.1.10",
"ws": "^8.22.0"
},
"devEngines": {
"packageManager": {
"name": "pnpm",
"version": "^12.4.1",
"onFail": "download"
}
}
"packageManager": "pnpm@12.16.1"
}
8 changes: 4 additions & 4 deletions packages/aws-lambda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dist/index.d.mts",
"import": "./dist/index.mjs",
"default": "./dist/index.mjs"
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"default": "./dist/index.js"
}
}
},
"scripts": {
"prepack": "unbuild"
"prepack": "tsc"
},
"dependencies": {
"@standard-server/core": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-lambda/src/body.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Buffer } from 'node:buffer'

import type { AsyncIteratorClass } from '@standard-server/shared'

import { toStandardBody } from './body'
import type { AnyAPIGatewayProxyEvent, APIGatewayProxyEvent } from './types'
import { toStandardBody } from './body.ts'
import type { AnyAPIGatewayProxyEvent, APIGatewayProxyEvent } from './types.ts'

function event(override: Partial<APIGatewayProxyEvent>): APIGatewayProxyEvent {
return {
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-lambda/src/body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
import { toAsyncIteratorObject } from '@standard-server/fetch'
import { parseEmptyableJSON } from '@standard-server/shared'

import { toStandardHeaders } from './headers'
import type { AnyAPIGatewayProxyEvent } from './types'
import { toStandardHeaders } from './headers.ts'
import type { AnyAPIGatewayProxyEvent } from './types.ts'

export interface ToStandardBodyOptions {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-lambda/src/headers.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { toLambdaHeaders, toStandardHeaders } from './headers'
import { toLambdaHeaders, toStandardHeaders } from './headers.ts'

describe('toStandardHeaders (v2)', () => {
it('lowercases keys and restores the cookie header', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-lambda/src/headers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { StandardHeaders } from '@standard-server/core'
import { toArray } from '@standard-server/shared'

import type { AnyAPIGatewayProxyEvent } from './types'
import type { AnyAPIGatewayProxyEvent } from './types.ts'

/**
* Convert API Gateway proxy event headers to standard headers.
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-lambda/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as index from '.'
import * as index from './index.ts'

it('export something', () => {
expect(Object.keys(index).length).toBeGreaterThan(0)
Expand Down
12 changes: 6 additions & 6 deletions packages/aws-lambda/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './body'
export * from './headers'
export * from './request'
export * from './response'
export * from './types'
export * from './url'
export * from './body.ts'
export * from './headers.ts'
export * from './request.ts'
export * from './response.ts'
export * from './types.ts'
export * from './url.ts'
Loading
Loading