| 582 | } |
| 583 | |
| 584 | const registerHandler = ( |
| 585 | self: Handlers<any, any, any>, |
| 586 | identifier: string, |
| 587 | handler: HttpApiEndpoint.Handler<HttpApiEndpoint.Constraint, any, any>, |
| 588 | isRaw: boolean, |
| 589 | options?: HandlerOptions | undefined |
| 590 | ) => { |
| 591 | if (!Object.hasOwn(self.group.endpoints, identifier)) { |
| 592 | throw new Error(`HttpApiEndpoint "${identifier}" not found in HttpApiGroup "${self.group.identifier}"`) |
| 593 | } |
| 594 | if (self.handlers.has(identifier)) { |
| 595 | throw new Error( |
| 596 | `Handler for HttpApiEndpoint "${identifier}" is already registered in HttpApiGroup "${self.group.identifier}"` |
| 597 | ) |
| 598 | } |
| 599 | const endpoint = self.group.endpoints[identifier] |
| 600 | self.handlers.set(identifier, { |
| 601 | endpoint, |
| 602 | handler, |
| 603 | isRaw, |
| 604 | uninterruptible: options?.uninterruptible ?? false |
| 605 | }) |
| 606 | return self |
| 607 | } |
| 608 | |
| 609 | const HandlersProto = { |
| 610 | [HandlersTypeId]: HandlersTypeId, |