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

Spike: Create a custom Sequence in JSLB4 #2475

Closed
hacksparrow opened this issue Feb 26, 2019 · 2 comments
Closed

Spike: Create a custom Sequence in JSLB4 #2475

hacksparrow opened this issue Feb 26, 2019 · 2 comments

Comments

@hacksparrow
Copy link
Contributor

Follow up task for #1978.

Acceptance criteria

a. Should be created as a class
b. Demonstrate usage with JSLB4 Application class

@bajtos bajtos changed the title Spike: Create Sequence in JSLB4 Spike: Create custom Sequence in JSLB4 Feb 26, 2019
@bajtos bajtos changed the title Spike: Create custom Sequence in JSLB4 Spike: Create a custom Sequence in JSLB4 Feb 26, 2019
@bajtos
Copy link
Member

bajtos commented Feb 26, 2019

Renamed the story to "Spike: Create a custom Sequence in JSLB4".

I think it's important to change the default request processing in the new Sequence class, otherwise there is no point in having a custom sequence IMO. To keep this simple, I am proposing to add a minimal request logging.

class MySequence {
  // ...

  async handle(context: RequestContext) {
    try {
      const {request, response} = context;
      const route = this.findRoute(request);
      const args = await this.parseParams(request, route);
      const result = await this.invoke(route, args);
      this.send(response, result);
    } catch (error) {
      this.reject(context, error);
    }

    // Example log:
    //   GET /products 200 OK
    console.log(
      request.method,
      request.url,
      response.statusCode,
      response.statusMessage,
    );
  }

@hacksparrow
Copy link
Contributor Author

Closing as per the decision taken in #2567.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants