Giter VIP home page Giter VIP logo

slushy's People

Contributors

aimed avatar dependabot-preview[bot] avatar dependabot[bot] avatar gribeiro-freighthub avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

slushy's Issues

Custom errors for file upload middleware

Ideally we map all errors caused by internal middleware/etc to SlushyErrors that can then be handled by the error handler.

  • Support AJV validation error
  • Support multer error

Error handling could be provided on a per resource or a per operation basis.

Handle response codes other than 200

Responses currently only support response code 200 for non error responses, otherwise anything supported by custom errors

Supporting other MIME types is a lower priority now, but slushy needs to be able to support different response codes and the appropriate response bodies in a typed manner.

There are a few different approaches to this:

Approach 1:
Request handlers always return an object that includes the status code as well as the payload (and maybe mime type). This can be fully typed, but requires more manual error handling and introduces the concept of response codes to request handlers.

getPets() {
  if (error) {
    return {
     status: 400,
     payload: { message: 'An error ocured' }
    }
  }
  return {
   status: 200,
   payload: []
  }
}

Approach 2:
Generate objects for responses and errors, e.g.

getPets() {
  if (error) { throw new GetPetsBadRequestError() }
  return new GetPetsSuccess([])
}

Approach 3:
Generate errors, but for responses use conventions, e.g. get must be 200, post bust me 201, delete must be 204

getPets() {
  if (error) { throw new GetPetsBadRequestError() }
  return []
}

[RFC] Pub/Sub extensions

Extend the OpenApi schema to support PubSub. Defining PubSub inside of events allows us to generate typed clients that know how to subscribe to events. It furthermore allows to generate typed servers that understand what these events look like and how events can be published. For an example of the schema as well as the generated code see the sections below.

In addition to generating types and handling them in a type safe and validated way, defining the PubSub mechanism inside of the schema would enable deployment pipelines to automatically perform the necessary bootstrapping. E.g. A deployment pipeline could inspect the publishers section and then set up a new AWS Queue.

Requirements:

  • Support different PubSub mechanisms (e.g. local, SQS, SNS)

Related work:

Publishing describes how a service publishes events and what shape the events have.
Example publishing:

publishes:
  petShopEvents:
    schema:
        $ref: "#/components/events/PetShopEvent"
    sources:
      SNS:
        arn: {petShopEventsSNSArn}:pet-shop-events
        encoding: application/json
        variables:
          petShopEventsSNSArn:
            type: string

Subscriptions describe how the service connects to publishers. In the case of SNS/SQS a deployment pipeline could create the actual subscription on AWS while Slushy takes care of listening to the events and forwarding them to the appropriate endpoint.
Example subscription:
TODO

subscriptions:
  petShopEvents:
    SQS:
       arn: {petShopEventsSQSArn}:pet-shop-events
       # This references the SNS services this queue is subscribed to. It provides the url and the expected schema.
       SNS:
         # This publisher has write permissions
         permissions: ["SQS:SendMessage"]
         $ref: 'https://my-schemas/petShop/#/publishes/petShopEvents/SNS'

Example code generated:
TODO

Add more robust error handling

Currently all error handling is done inside of SlushyRouter. This has a few caveats:

  • Middleware errors, e.g. parsing, validation (see below), etc. will be not handled correctly.
  • If the router handler fails, the error will not be handled correctly.

See also #85.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.