Commit 0d96582
authored
feat: refactor SSE queue, expand test coverage, fix package metadata (#36)
* feat: expand tests, add ESLint, document env vars
- Add 17 new integration tests: CORS edge cases (disallowed origins,
no-origin header, OPTIONS for disallowed origin), auth (401/pass-through),
and error handling (400/502/404) for /v1/chat/completions
Closes #14, closes #16
- Add ESLint with flat config, npm run lint script, and Lint job in CI
Closes #15
- Improve README with quickstart section, npm install instructions, and
corrected package name; add type column to env vars table
Closes #17
* feat: implement SSE streaming and support all opencode providers
- Implement streaming for POST /v1/chat/completions (issue #11):
subscribe to opencode event stream, pipe message.part.updated deltas
as SSE chat.completion.chunk events, finish on session.idle
- Implement streaming for POST /v1/responses (issue #11):
emit response.created / output_text.delta / response.completed events
- Fix provider-agnostic system prompt hint (issue #12): remove
'OpenAI-compatible' wording so non-OpenAI models are not confused
- Add TextEncoder and ReadableStream to ESLint globals
- Add streaming integration tests (happy path, unknown model, session.error)
* feat: refactor SSE queue, expand test coverage, fix package metadata
- Extract createSseQueue() helper, eliminating duplicated SSE queue pattern
in /v1/chat/completions and /v1/responses streaming branches (closes #34)
- Add tests for GET /v1/models happy path, empty providers, and error path (closes #33)
- Add tests for POST /v1/responses: happy path, validation, streaming, session.error (closes #32)
- Fix package.json description to be provider-agnostic (closes #35)
- Add engines field declaring bun >=1.0.0 requirement (closes #35)
- Line coverage: 55% -> 89%, function coverage: 83% -> 94%1 parent a6817bf commit 0d96582
3 files changed
Lines changed: 432 additions & 73 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
487 | 487 | | |
488 | 488 | | |
489 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
490 | 532 | | |
491 | 533 | | |
492 | 534 | | |
| |||
595 | 637 | | |
596 | 638 | | |
597 | 639 | | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
| 640 | + | |
610 | 641 | | |
611 | 642 | | |
612 | 643 | | |
| |||
622 | 653 | | |
623 | 654 | | |
624 | 655 | | |
625 | | - | |
| 656 | + | |
626 | 657 | | |
627 | 658 | | |
628 | 659 | | |
| |||
638 | 669 | | |
639 | 670 | | |
640 | 671 | | |
641 | | - | |
| 672 | + | |
642 | 673 | | |
643 | 674 | | |
644 | 675 | | |
| |||
649 | 680 | | |
650 | 681 | | |
651 | 682 | | |
652 | | - | |
| 683 | + | |
653 | 684 | | |
654 | 685 | | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
| 686 | + | |
661 | 687 | | |
662 | 688 | | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
| 689 | + | |
676 | 690 | | |
677 | 691 | | |
678 | 692 | | |
| |||
739 | 753 | | |
740 | 754 | | |
741 | 755 | | |
742 | | - | |
743 | | - | |
744 | | - | |
745 | | - | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
| 756 | + | |
754 | 757 | | |
755 | 758 | | |
756 | 759 | | |
757 | 760 | | |
758 | 761 | | |
759 | 762 | | |
760 | | - | |
| 763 | + | |
761 | 764 | | |
762 | 765 | | |
763 | 766 | | |
| |||
770 | 773 | | |
771 | 774 | | |
772 | 775 | | |
773 | | - | |
| 776 | + | |
774 | 777 | | |
775 | 778 | | |
776 | 779 | | |
| |||
786 | 789 | | |
787 | 790 | | |
788 | 791 | | |
789 | | - | |
| 792 | + | |
790 | 793 | | |
791 | 794 | | |
792 | 795 | | |
| |||
797 | 800 | | |
798 | 801 | | |
799 | 802 | | |
800 | | - | |
| 803 | + | |
801 | 804 | | |
802 | 805 | | |
803 | 806 | | |
| |||
809 | 812 | | |
810 | 813 | | |
811 | 814 | | |
812 | | - | |
| 815 | + | |
813 | 816 | | |
814 | 817 | | |
815 | 818 | | |
| |||
818 | 821 | | |
819 | 822 | | |
820 | 823 | | |
821 | | - | |
| 824 | + | |
822 | 825 | | |
823 | 826 | | |
824 | 827 | | |
825 | 828 | | |
826 | 829 | | |
827 | 830 | | |
828 | | - | |
| 831 | + | |
829 | 832 | | |
830 | 833 | | |
831 | 834 | | |
| |||
849 | 852 | | |
850 | 853 | | |
851 | 854 | | |
852 | | - | |
| 855 | + | |
853 | 856 | | |
854 | 857 | | |
855 | 858 | | |
| |||
863 | 866 | | |
864 | 867 | | |
865 | 868 | | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
| 869 | + | |
872 | 870 | | |
873 | 871 | | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | | - | |
878 | | - | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | | - | |
| 872 | + | |
886 | 873 | | |
887 | 874 | | |
888 | 875 | | |
| |||
0 commit comments