We have two route handler "helpers" that you currently access off of a route handler's this context: serialize and normalizedRequestAttrs. This is super confusing because it prevents you from being able to use fat arrow functions.
// whoops! won't work.
this.get('/users', (schema, request) => {
let json = this.serialize(schema.users.all())
});
// now it works.
this.get('/users', function(schema, request) {
let json = this.serialize(schema.users.all())
});
This sucks. But now that we have destructuring we have a much better way to make these helpers available - injection!
No more this, just grab the helper from the argument if you need it! Now you can use fat arrows all the time.
The Response API is kinda awkward and feels like a big step to take just to customize the response code. We have a weird shorthand version that can do it but it might be better to revisit this. If we make change 2, we could possibly inject a response function that could be used more easily.
I would suggest to make request API to be more fetch friendly to match with Request class as much as possible), eq. having request.headers to be an instance of Headers class will simplify dealing with headers like case insensitivity.
Wanted to start collecting some APIs I'm consider changing/breaking, just because they feel very outdated.
Route handlers should have a single object as their sole argument, and
schema
andrequest
should be destructurable properties from it.We should also add
db
and perhaps other things.We have two route handler "helpers" that you currently access off of a route handler's
this
context:serialize
andnormalizedRequestAttrs
. This is super confusing because it prevents you from being able to use fat arrow functions.This sucks. But now that we have destructuring we have a much better way to make these helpers available - injection!
No more
this
, just grab the helper from the argument if you need it! Now you can use fat arrows all the time.The
Response
API is kinda awkward and feels like a big step to take just to customize the response code. We have a weird shorthand version that can do it but it might be better to revisit this. If we make change 2, we could possibly inject aresponse
function that could be used more easily.