Refactor: Elysia best-practice service layer - #4
Draft
injoon5 wants to merge 5 commits into
Draft
Conversation
Move NEIS/Comcigan business logic out of app.ts into focused service modules with a shared NEIS client factory. Query/response types derive from Typebox schemas (SchoolQuery, composite query objects). Slim app.ts to route wiring, model refs, and error handling. Tests use Static types from response schemas. Co-authored-by: Injoon Oh <injoon5@icloud.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Organize routes under src/modules/{meta,school,classes,timetable,lunch,schedule}
- Centralize NEIS mapping in schemas/mappers.ts; shared school/neis in src/shared/
- SchoolSearchQuery, ApiErrorBody from schema Static types; rename ApiError.status to httpStatus (Elysia bypass fix)
- modelsPlugin per module; register onError before .use(modules)
- Add school-validation unit test; remove handleRoute wrapper
Co-authored-by: Injoon Oh <injoon5@icloud.com>
Co-authored-by: Injoon Oh <injoon5@icloud.com>
Co-authored-by: Injoon Oh <injoon5@icloud.com>
Scalar needs servers in the spec to run Try-it requests. Add a relative /current-host server, keep production and local entries, and enable embedSpec so the spec (with servers) ships inline on /docs. Co-authored-by: Injoon Oh <injoon5@icloud.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Full Elysia best-practice alignment: feature modules, shared services, typed models, and a critical error-handling fix.
Structure
Audit fixes
src/modules/*per guidehandleRouteonErrorhandlesApiErrorBodyStatic<typeof ApiErrorSchema>SchoolSearchQueryGET /schoolschemas/mappers.tscreateNeisClient()src/test/school-validation.tsApiError.status→httpStatus;.onErrormust be registered before.use(modules)Test plan
npm run buildnpm test(school-validation + compare + yangjeong)