Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Next.js 15 async params #3

Merged
merged 1 commit into from
Oct 21, 2024
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
116 changes: 15 additions & 101 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -1,115 +1,29 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"css": {
"formatter": {
"enabled": true
}
},
"files": {
"ignore": ["./.vscode/*.json", "./migrations/"]
},
"formatter": {
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
"vcs": {
"enabled": true,
"indentStyle": "space"
},
"javascript": {
"formatter": {
"semicolons": "asNeeded",
"trailingCommas": "none"
}
"clientKind": "git",
"useIgnoreFile": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"noUndeclaredVariables": {
"level": "warn"
},
"noUnusedImports": {
"level": "warn",
"fix": "none"
},
"noUnusedPrivateClassMembers": {
"level": "warn"
},
"noUnusedVariables": {
"level": "warn",
"fix": "none"
},
"useHookAtTopLevel": {
"level": "warn",
"options": {}
}
},
"nursery": {
"noDuplicateElseIf": {
"level": "warn"
},
"noDuplicateJsonKeys": {
"level": "warn"
},
"noMisplacedAssertion": {
"level": "warn"
},
"noUnusedFunctionParameters": {
"level": "warn"
},
"noUselessStringConcat": {
"level": "warn"
},
"noYodaExpression": {
"level": "warn"
},
"useAdjacentOverloadSignatures": {
"level": "warn"
},
"useDateNow": {
"level": "warn"
},
"useErrorMessage": {
"level": "warn"
},
"useSemanticElements": {
"level": "warn"
},
"useThrowNewError": {
"level": "warn"
}
},
"style": {
"useBlockStatements": {
"level": "warn"
},
"useCollapsedElseIf": {
"level": "warn"
},
"useFilenamingConvention": {
"level": "warn",
"options": {
"requireAscii": true
}
},
"useForOf": {
"level": "warn"
}
},
"suspicious": {
"noEmptyBlockStatements": {
"level": "warn"
},
"useAwait": {
"level": "warn"
}
}
"recommended": true
}
},
"organizeImports": {
"enabled": false
},
"vcs": {
"formatter": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
"indentStyle": "space",
"indentWidth": 2
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"semicolons": "asNeeded",
"trailingCommas": "none"
}
}
}
Binary file modified bun.lockb
Binary file not shown.
7 changes: 3 additions & 4 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@ export type ApiResponse<T> = T | ApiResponseError
* The default value of the next.js route parameter
*/
export const nextRouteParamsSchema = z.record(
z.union([z.string(), z.array(z.string())])
z.union([z.string(), z.array(z.string()), z.undefined()])
)
export type NextRouteParams = z.infer<typeof nextRouteParamsSchema>

/**
* The Context parameter for route handlers, which is currently an optional
* `params` object.
* The Context parameter for route handlers, which is currently a `params` promise.
*
* See: https://nextjs.org/docs/app/api-reference/file-conventions/route#context-optional
*/
export interface NextRouteContext<U = NextRouteParams> {
params?: U
params: Promise<U>
}

/**
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typed-route-handler",
"version": "0.3.0",
"version": "0.4.0-canary.1",
"description": "Type-safe route handlers for Next.js",
"keywords": ["next", "route handler", "typescript", "api"],
"homepage": "https://github.com/venables/typed-route-handler#readme",
Expand Down Expand Up @@ -34,25 +34,25 @@
"files": ["dist/**/*", "client/**/*"],
"scripts": {
"build": "tsup",
"check": "biome check . && bun run type-check && bun test",
"check": "biome check . && bun run typecheck && bun test",
"clean": "git clean -xdf dist client",
"format": "biome format --write .",
"format:check": "biome format .",
"lint": "biome lint .",
"outdated": "npx npm-check-updates --interactive --format group",
"prepublish": "bun run build",
"type-check": "tsc --noEmit --pretty"
"typecheck": "tsc --noEmit --pretty"
},
"dependencies": {},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@types/bun": "^1.1.6",
"tsup": "^8.1.0",
"tsx": "^4.16.2",
"typescript": "^5.5.3"
"@biomejs/biome": "1.9.3",
"@types/bun": "^1.1.11",
"tsup": "^8.3.0",
"tsx": "^4.19.1",
"typescript": "^5.6.3"
},
"peerDependencies": {
"next": ">= 13",
"next": ">= 15",
"zod": ">= 3.22"
}
}