Hacker News new | ask | show | jobs
by activitypea 1307 days ago

    export class TaskController extends Controller {

        @use(StoreTaskRequest)

        store(request: StoreTaskRequest): void {

            const description: string = request.get('description')

        }

I've done enough Spring Boot to know I never want to do Spring Boot in my life again.
4 comments

Yeah, decorators were a mistake. I don't want any in my code or my dependencies.
Why does it need the use if its already a parameter?
It’s a dependency injection pattern. The decorator is telling some other piece of code what to pass in to that method, or to set some hidden context.

I’d check the docs for what it specifically does, but the site is completely unusable on iOS.

It would make more sense if the injected variable was an interface, the decorator telling you what the concencrete type should be. I think? Otherwise, yeah totally pointless.
So this is only meant for DI, and the main benefit is request validation. You could also opt to use the controller's validation helper if you don't want to use the `@use` decorator.
Help me out here, what does that bit of JS have to do with Spring Boot?
Magic decorators is the trigger, I think.
Probably that @use thing?
I share the hate.