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

[EPIC] Create new socketio package based on @tsed/schema #2453

Open
3 of 14 tasks
Romakita opened this issue Sep 28, 2023 · 0 comments
Open
3 of 14 tasks

[EPIC] Create new socketio package based on @tsed/schema #2453

Romakita opened this issue Sep 28, 2023 · 0 comments
Assignees

Comments

@Romakita
Copy link
Collaborator

Romakita commented Sep 28, 2023

Is your feature request related to a problem? Please describe.

@tsed/socketio use own metadata storage. It's a problem because we cannot share the code to create SocketService with a Rest Controller.

Describe the solution you'd like

As is explained this discussion around Async API #1952, the new package should be able to generate the Async API Documentation.

The goal is to be able to declare both a Rest controller and a Websocket controller as follows:

class PetCategory {
  @Required()
  @Groups("!partial", "!create", "!update")
  id: string;

  @Required()
  @Example("doggie")
  name: string;
}

enum PetStatus {
  AVAILABLE = "available",
  PENDING = "pending",
  SOLD = "sold"
}

class Pet {
  @Required()
  @Groups("!partial", "!create", "!update")
  id: string;

  @Required()
  @Example("doggie")
  name: string;

  @Property()
  category: PetCategory;

  @CollectionOf(String)
  tags: string[];

  @Enum(PetStatus)
  status: PetStatus;
}

@Controller("/")
@Name("PetStore")
class PetController {
  @Use("/")
  middleware(@PathParams("id") id: string) {}

  @Get("/:id")
  @Publish("pet.get")
  @Subscribe("pet.get")
  @Returns(200, Pet).Description("Returns a pet")
  @Returns(404)
  get(@PathParams("id") id: string) {
    return null;
  }

  @Get("/")
  @Publish("pet.getAll")
  @Subscribe("pet.getAll")
  @Returns(200, Array).Of(Pet).Description("Returns all pets")
  getAll() {
    return [];
  }

  @Patch("/:id")
  @Publish("pet.patch")
  @Subscribe("pet.updated")
  @Returns(200, Pet).Description("Returns a pet")
  @Returns(404)
  @Description("Patch a pet")
  patch(@PathParams("id") id: string, @BodyParams() @Partial() partial: Pet) {
    return null;
  }

  @Post("/:id")
  @Publish("pet.update")
  @Subscribe("pet.created")
  @Returns(200, Pet).Description("Returns a pet")
  @Returns(404)
  @Description("Update a pet")
  post(@BodyParams() @Groups("update") pet: Pet) {
    return null;
  }

  @Put("/")
  @Publish("pet.create")
  @Subscribe("pet.updated")
  @Returns(201, Pet)
  @Returns(404)
  @Description("Create a pet")
  put(@BodyParams() @Groups("create") pet: Pet) {
    return null;
  }

  @Delete("/:id")
  @Publish("pet.delete")
  @Subscribe("pet.deleted")
  @Returns(204)
  @Returns(404)
  @Description("Delete a pet")
  delete(@PathParams("id") id: string) {
    return null;
  }
}

Tasks

  • Implement @Subscribe and @Publish decorator on @tsed/schema package (PR: Feat socket io #186 )
  • Implement mappers to generate Async API from getSpec function (`@tsed/schema) (PR: Feat socket io #186)
  • Update @tsed/platform-routers to filter SUBSCRIBE and PUBLISH verbs.
  • Update @tsed/platform-routers to be reused to generate layers for socket platform.
  • Create a @tsed/socketio-v2 package and add private tags on this package.
  • Create a @tsed/async-api-ui package to generate doc and serve the Async API UI
  • Use @tsed/platform-routers to map WS Layers
  • Deprecate the @tsed/socketio package
  • Update documentation

Acceptance criteria

  • The new package use @tsed/schema
  • The new package support @tsed/json-mapper
  • The new package support middlewares
  • The new package support the Context
  • The new package can generate the Async API Documentation
@Romakita Romakita self-assigned this Sep 28, 2023
@Romakita Romakita changed the title [EPIC] Create new socketio based on @tsed/schema [EPIC] Create new socketio package based on @tsed/schema Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To do
Development

No branches or pull requests

1 participant