Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add billing module to handle /billing endpoints #398

Merged
merged 25 commits into from
Oct 16, 2020
Merged

Conversation

karrui
Copy link
Contributor

@karrui karrui commented Sep 30, 2020

馃棐 This PR is complete with the exception of integration tests for BillingRouter, see note below in the test section.

Problem

This PR extracts out billing related functions in various controllers and services and reorganises them into the modules/billing directory.

Related to #144

Solution

Features:

  • Add static aggregateLoginStats method to LoginModel so it can be easily used by services
  • Add BillingService#getSpLoginStats function to retrieve SingPass login statistics
  • Add BillingFactory to return correct function handler depending on whether spcp-myinfo feature is enabled in the Feature Manager
  • Add BillingController controller handler for /billing route
  • Replace current /billing route with the new BillingRouter

Tests

  • Add unit tests for billing.service
  • Add unit tests for billing.factory
  • Add unit tests for billing.controller

This will be delayed until #371 is merged in as that contains code for generated an authenticated session (or should I cherry pick the appropriate commits? Scared that will scare ppl off with the commit size again)

  • Add integration tests for billing.routes

@karrui karrui marked this pull request as draft September 30, 2020 09:35
@karrui karrui marked this pull request as ready for review October 1, 2020 04:39
@karrui karrui changed the title wip: add BillingRouter to handle /billing endpoints feat: add BillingRouter to handle /billing endpoints Oct 1, 2020
@karrui karrui changed the title feat: add BillingRouter to handle /billing endpoints feat: add Billing module to handle /billing endpoints Oct 1, 2020
@karrui karrui changed the title feat: add Billing module to handle /billing endpoints feat: add billing module to handle /billing endpoints Oct 1, 2020
# Conflicts:
#	src/config/feature-manager/util/FeatureManager.class.ts
Comment on lines +61 to +63
export const isUserInSession = (req: Request): boolean => {
return !!req.session?.user
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at some point we should also save the user ID and the user object into session, so that we can migrate off the user object at our convenience.

# Conflicts:
#	src/app/controllers/admin-console.server.controller.js
#	src/loaders/express/index.ts
# Conflicts:
#	src/app/controllers/admin-console.server.controller.js
#	src/app/factories/spcp-myinfo.factory.js
Copy link
Contributor

@mantariksh mantariksh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice! minor nits

endOfMonth.toDate(),
)

if (loginStatsResult.isErr()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the original code has a loginStatsResult.isOk() && !loginStatsResult.value case as well, is there any chance of that happening?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, aggregate always returns an array; but the array can be empty

src/app/modules/billing/billing.controller.ts Show resolved Hide resolved
@karrui karrui merged commit 77e7507 into develop Oct 16, 2020
@karrui karrui deleted the ref/ts-billing branch October 16, 2020 03:06
@tshuli tshuli mentioned this pull request Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants