luckyframework / luckyframework/lucky

Typed route path params

Open
#2,049 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Crystal
Stars
2.7k
Forks
172
PR merge metrics
No merged PRs in 30d

Description

Right now when you add a route path param, a method is created by that name and it returns a `String`.

I just recently had an issue where some javascript client is sending over `null` and doing `PostQuery.find("null")` borks the DB. So now I've gotta go adding all this logic to ensure the `:id` looks like a valid ID.

With this feature, you would just tell your route what the `:id` should look like, and if it doesn't look like that, then 404.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how route path params create methods that currently return String. Define how a route declares the expected shape for :id and how invalid values become a 404 instead of reaching lookup code. Done means typed route params reject values such as "null" before the database query runs.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.