Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update getPublicForm endpoint to typescript (#1398)
* refactor(modules/spcp): shifts get spcp session out into service * refactor(modules/form): adds utility methods and refactored checkFormSubmission * refactor(modules/form): refactors GET public forms end point from js to ts * refactor(utils): adds utility type for all possible db errors * fix(types/form): fixed the type of submissionLimit to allow for null * refactor(modules/form): updated deactiveForm so that it uses never throw and adds logging * refactor(modules/form): updated form limit checking to account for submission limit being null * refactor(modules/form): adds logging to getSpcpSession * refactor(modules/form): refactored handleGetPublicForm for clarity and code cleanliness * refactor(publicformctrl): refactored handler for GET public forms to be cleaner and easier to read * refactor(spcpsvc): added logging to extract JWT; updated typings for getSpcpSession * revert(formsvc): removes retrievePublicForm (will be done in another PR) to limit scope * style(public-form/controller): updated object to use variables * style(services/types): updated documentation for functions and removed unneeded logging * refactor(public-form/controller): refactored spcp flow so it's clearer * refactor(public-form/controller): wip for myInfo * refactor(myinfo): extracts myInfoCookiePayload to 2 types and adds utility function to differentiate * refactor(public-form/controller): refactored myinfo chunk so it's neater * test(form/service): fixes failing tests due to checkFormSubmissionLimitAndDeactivateForm * refactor(myinfo): removed unneeded cookie type and updated extractSuccessfulCookie to reflect this * docs(public-form/controller): adds docs to confusing sections of handlGetPublicForm * test(public-form/controller/test): add test for database error when GET /getPublicForm * test(public-form/controller/tests): add more tests * test(public-form/controller/test): adds test for success cases * refactor(myinfo): extracts out chunks form public-form controller into myinfo service * refactor(public-form/controller): updated controller to use MyInfoFactory method * test(public-form/controller/test): updated tests to use mocks * fix(public-form/controller): fixed succesful 200 when auth using myInfo returning a private view * test(public-form/controller/test): adds remaining tests for myInfo * refactor(spcp): combined controller calls to spcp services into a single spcp call * refactor(myinfo): refactored multiple controller calls to myInfo into a single call * refactor(public-form): updated typings and refactored getPublicForm to be cleaner * style(public-form/controller/test): updated comments in tests to use when * refactor(form/service): updated deactiveForm to return the form itself; updated tests * style(myinfo): extractMyInfoData renamed to fetchMyInfoData * fix(public-form/controller): fixed bug where wrong extract cookie method is being called * refactor(spcp/myinfo): removed extra logging in spcp; updated names in myinfo * test(spcp/service/test): adds service tests * test(spcp/service/test): adds unit tests for createFormWithSpcpSession * test(myinfo.service): adds tests for createFormWithMyInfo * feat(form): adds new errors and utility methods * refactor(public-form): refactor to account for intarnet * refactor(public-form/controller): added compatability for checking intranet access * test(public-form/controller): adds tests for checking intranet; fixes old tests due to this addition * style(spcp/service/test): changed naming to camelCase for variables * fix(form.service): fixed intranet ip checking * refactor(public-form): shifts utility method out into public form service * test(public-form/controller): updates tests * refactor(public-forms/server/routes): swaps to new controller for express middleware * fix(myinfo/util): added cookie access check * fix(form/service): adds error recovery for missing feature error when checking intranet access * refactor(public-form/controller): tightened logic for myinfo error * build(package.json): added ts-essential for UnreachableCaseException * refactor(forms): added new type for intranet form * refactor(spcp/service): updated service methods * refactor(intranet/factory): updated isIntranetIp and factory signature typings * refactor(myinfo): updated typings and factory methods to remove responsibility from service * refactor(public-form/controller): wip * refactor(form/service): remove result wrapping as only error is MissingFeatureError * refactor(myinfo): updated typings and comments for myInfo * refactor(publicform): updated handleGetPublicForm method and removed unused types * refactor(public-form/service): removed unnused method * fix(public-form/controller): changed returned form to be a publicForm * test(myinfo/service): updated tests for myinfo service * test(public-form/controller): updated tests to fit iwth refactor * chore(intranet): removed unused variables * test(intranet/service): fixes failing tests due to refactor * refactor(app/utils): removed duplicate datatype in handle mongo errors * style(form/service): updated logger message * test(spcp/service): removed tests for deleted method; updated test for getSpcpSession * refactor(public-form/controller): extracts logger meta property into a variable * style(form/service): updated action property of logger meta * docs(public-form/controller): updated comments for getPublicForm on conditions for myInfoError * refactor(myinfo): deleted unused middleware; made fetchMyInfoPersonData private * refactor(myinfo): changed fetchMyInfoPersonData to become a private field * test(myinfo): fixed factory and service tests due to making myInfoPersonData private * chore(webhook/service/test): fixed import * chore(types/forms): removed unused type declaration * style(form/service): chains calls together for clarity * refactor(myinfo): refactored methods so that atomic operations are performed together * test(myinfo): fixes tests for myinfo * style(spcp): renamed service methods for clarity; removed unused error * test(spcp): fixes spcp tests * refactor(public-form): updated controller to account for myinfo/spcp refactoring * test(public-form): updated tests * fix(public-form/controller): fixed cp returning userInfo as ewll
- Loading branch information