| 42 | const idParam = HttpApiSchema.param("id", Schema.NumberFromString) |
| 43 | |
| 44 | class UsersApi extends HttpApiGroup.make("users") |
| 45 | .add( |
| 46 | HttpApiEndpoint.get("findById")`/${idParam}` |
| 47 | .addSuccess(User) |
| 48 | .setHeaders(Schema.Struct({ |
| 49 | page: Schema.NumberFromString.pipe( |
| 50 | Schema.optionalWith({ default: () => 1 }) |
| 51 | ) |
| 52 | })) |
| 53 | .addError(Schema.String.pipe( |
| 54 | HttpApiSchema.asEmpty({ status: 413, decode: () => "boom" }) |
| 55 | )) |
| 56 | ) |
| 57 | .add( |
| 58 | HttpApiEndpoint.post("create", "/") |
| 59 | .setPayload(HttpApiSchema.Multipart(Schema.Struct({ |
| 60 | name: Schema.String |
| 61 | }))) |
| 62 | .addSuccess(User) |
| 63 | ) |
| 64 | .add( |
| 65 | HttpApiEndpoint.get("me", "/me") |
| 66 | .addSuccess(User) |
| 67 | ) |
| 68 | .middleware(Authentication) |
| 69 | .prefix("/users") |
| 70 | .annotateContext(OpenApi.annotations({ |
| 71 | title: "Users API", |
| 72 | description: "API for managing users" |
| 73 | })) |
| 74 | {} |
| 75 | |
| 76 | class TopLevelApi extends HttpApiGroup.make("topLevel", { topLevel: true }) |
| 77 | .add( |
nothing calls this directly
no test coverage detected
searching dependent graphs…