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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General housekeeping #35

Merged
merged 6 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/controllers/health/airbrake.controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
'use strict'

/**
* Controller for /health/airbrake endpoints
* @module AirbrakeController
*/

class AirbrakeController {
static async index (request, _h) {
// First section tests connecting to Airbrake through a manual notification
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/health/database.controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
'use strict'

const DatabaseHealthCheckService = require('../../services/database_health_check.service.js')
/**
* Controller for /health/database endpoints
* @module DatabaseController
*/

const DatabaseHealthCheckService = require('../../services/database-health-check.service.js')

class DatabaseController {
static async index (_request, h) {
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/root.controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
'use strict'

const ServiceStatusService = require('../services/service_status.service')
/**
* Controller for / endpoints
* @module SupplementaryController
*/

const ServiceStatusService = require('../services/service-status.service.js')

class RootController {
static async index (_request, _h) {
Expand Down
9 changes: 7 additions & 2 deletions app/controllers/test/supplementary.controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
'use strict'

const FindRegionService = require('../../services/supplementary_billing/find_region.service')
const SupplementaryService = require('../../services/supplementary_billing/supplementary.service.js')
/**
* Controller for /test/supplementary endpoints
* @module SupplementaryController
*/

const FindRegionService = require('../../services/supplementary-billing/find-region.service.js')
const SupplementaryService = require('../../services/supplementary-billing/supplementary.service.js')

class SupplementaryController {
static async index (request, h) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

/**
* Base class for notification managers
* @module BaseNotifierLib
*/

Expand Down
5 changes: 3 additions & 2 deletions app/lib/boom_notifier.lib.js → app/lib/boom-notifier.lib.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
'use strict'

/**
* A combined logging and Airbrake (Errbit) notification manager
* @module BoomNotifierLib
*/

const RequestNotifierLib = require('./request_notifier.lib.js')

const Boom = require('@hapi/boom')

const RequestNotifierLib = require('./request-notifier.lib.js')

/**
* A combined logging and Airbrake (Errbit) notification manager which extends RequestNotifierLib to also throw a Boom
* `400` error if the .omfg method is called.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict'

/**
* A combined logging and Airbrake (Errbit) notification manager
* @module RequestNotifierLib
*/

const BaseNotifierLib = require('./base_notifier.lib.js')
const BaseNotifierLib = require('./base-notifier.lib.js')

/**
* A combined logging and Airbrake (Errbit) notification manager for actions that take place within a
Expand Down
1 change: 1 addition & 0 deletions app/models/base.model.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

/**
* Base class for all Objection-based models
* @module BaseModel
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

/**
* Model for water.charge_versions
* @module ChargeVersionModel
*/

Expand Down
3 changes: 2 additions & 1 deletion app/models/licence.model.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

/**
* Model for water.licences
* @module LicenceModel
*/

Expand All @@ -17,7 +18,7 @@ class LicenceModel extends BaseModel {
return {
chargeVersions: {
relation: Model.HasManyRelation,
modelClass: 'charge_version.model',
modelClass: 'charge-version.model',
join: {
from: 'water.licences.licence_id',
to: 'water.charge_versions.licence_id'
Expand Down
1 change: 1 addition & 0 deletions app/models/region.model.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

/**
* Model for water.regions
* @module RegionModel
*/

Expand Down
2 changes: 2 additions & 0 deletions app/plugins/airbrake.plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

/**
* Plugin to log errors using Airbrake API
* @module AirbrakePlugin
*/

Expand All @@ -18,6 +19,7 @@
*/

const { Notifier } = require('@airbrake/node')

const AirbrakeConfig = require('../../config/airbrake.config.js')

const AirbrakePlugin = {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

const HapiPino = require('hapi-pino')

const HapiPinoIgnoreRequestService = require('../services/plugins/hapi_pino_ignore_request.service.js')
const HapiPinoIgnoreRequestService = require('../services/plugins/hapi-pino-ignore-request.service.js')

/**
* Return test configuration options for the logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @module RequestNotifierPlugin
*/

const RequestNotifierLib = require('../lib/request_notifier.lib.js')
const RequestNotifierLib = require('../lib/request-notifier.lib.js')

const RequestNotifierPlugin = {
name: 'Notifier',
Expand Down
6 changes: 3 additions & 3 deletions app/plugins/router.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
* @module RouterPlugin
*/

const FilterRoutesService = require('../services/plugins/filter_routes.service.js')
const AirbrakeConfig = require('../../config/airbrake.config.js')

const AirbrakeRoutes = require('../routes/airbrake.routes.js')
const AssetRoutes = require('../routes/assets.routes.js')
const DatabaseRoutes = require('../routes/database.routes.js')
const FilterRoutesService = require('../services/plugins/filter-routes.service.js')
const RootRoutes = require('../routes/root.routes.js')
const TestRoutes = require('../routes/test.routes.js')

const AirbrakeConfig = require('../../config/airbrake.config.js')

const routes = [
...RootRoutes,
...AirbrakeRoutes,
Expand Down
6 changes: 4 additions & 2 deletions app/plugins/views.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
* @module ViewsPlugin
*/

const SERVICE_NAME = 'Manage your water abstraction or impoundment licence'

const path = require('path')
const nunjucks = require('nunjucks')

const pkg = require('../../package.json')

const ServerConfig = require('../../config/server.config.js')

const SERVICE_NAME = 'Manage your water abstraction or impoundment licence'

const ViewsPlugin = {
plugin: require('@hapi/vision'),
options: {
Expand Down
1 change: 1 addition & 0 deletions app/presenters/supplementary.presenter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

/**
* Formats responses from the `SupplementaryService`
* @module SupplementaryPresenter
*/

Expand Down
2 changes: 1 addition & 1 deletion app/routes/test.routes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const SupplementaryController = require('../controllers/test/supplementary.controller')
const SupplementaryController = require('../controllers/test/supplementary.controller.js')

const routes = [
{
Expand Down
12 changes: 6 additions & 6 deletions app/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ require('dotenv').config()

const Hapi = require('@hapi/hapi')

const ServerConfig = require('../config/server.config.js')
const LogConfig = require('../config/log.config.js')

const AirbrakePlugin = require('./plugins/airbrake.plugin.js')
const BlippPlugin = require('./plugins/blipp.plugin.js')
const ErrorPagesPlugin = require('./plugins/error_pages.plugin.js')
const HapiPinoPlugin = require('./plugins/hapi_pino.plugin.js')
const RequestNotifierPlugin = require('./plugins/request_notifier.plugin.js')
const ErrorPagesPlugin = require('./plugins/error-pages.plugin.js')
const HapiPinoPlugin = require('./plugins/hapi-pino.plugin.js')
const RequestNotifierPlugin = require('./plugins/request-notifier.plugin.js')
const RouterPlugin = require('./plugins/router.plugin.js')
const StopPlugin = require('./plugins/stop.plugin.js')
const ViewsPlugin = require('./plugins/views.plugin.js')

const ServerConfig = require('../config/server.config.js')
const LogConfig = require('../config/log.config.js')

const registerPlugins = async (server) => {
// Register the remaining plugins
await server.register(StopPlugin)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

/**
* Used by the `DatabaseController` to determine if connection to the database is healthy
* @module DatabaseHealthCheckService
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

/**
* Used by the `RouterPlugin` to determine if a route should be registered with Hapi
* @module FilterRoutesService
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

/**
* Used by HapiPinoPlugin to determine which requests to log
* @module HapiPinoIgnoreRequestService
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
'use strict'

/**
* Checks status, including versions, of the various services which make up WRLS
* @module ServiceStatusService
*/

// We use promisify to wrap exec in a promise. This allows us to await it without resorting to using callbacks.
const util = require('util')
const ChildProcess = require('child_process')
const util = require('util')
const exec = util.promisify(ChildProcess.exec)

const servicesConfig = require('../../config/services.config')
const servicesConfig = require('../../config/services.config.js')

/**
* Returns data required to populate our `/service-status` page, eg. task activity status, virus checker status, service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

/**
* Calculates billing periods needed when generating a supplementary bill run
* @module BillingPeriodService
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict'

/**
* Fetches SROC charge versions that might be included in a supplementary bill run
* @module FetchChargeVersionsService
*/

const { db } = require('../../../db/db')
const { db } = require('../../../db/db.js')

class FetchChargeVersionsService {
static async go (regionId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
'use strict'

/**
* Fetches a region based on the NALD region ID provided
* @module FindRegionService
*/

const { db } = require('../../../db/db')

/**
* @module FindRegionService
*/
const { db } = require('../../../db/db.js')

class FindRegionService {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict'

/**
* Determines the billing periods, licences and charge versions used to generate an SROC supplementary bill run
* @module SupplementaryService
*/

const BillingPeriodService = require('./billing_period.service')
const FetchChargeVersionsService = require('./fetch_charge_versions.service.js')
const BillingPeriodService = require('./billing-period.service.js')
const FetchChargeVersionsService = require('./fetch-charge-versions.service.js')
const SupplementaryPresenter = require('../../presenters/supplementary.presenter.js')

class SupplementaryService {
Expand Down
5 changes: 5 additions & 0 deletions config/airbrake.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
'use strict'

/**
* Config values used to connect to our Airbrake compatible error tracker (Errbit)
* @module AirbrakeConfig
*/

const config = {
host: process.env.AIRBRAKE_HOST,
projectKey: process.env.AIRBRAKE_KEY,
Expand Down
5 changes: 5 additions & 0 deletions config/database.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
'use strict'

/**
* Config values used to connect to PostgreSQL
* @module DatabaseConfig
*/

// Unlike the other config files we need to directly reference dotenv. It is because this config is used when we run
// migrations. The rest of the config is only used when we run the app. `app/server.js` loads dotenv which makes it
// available to everything else thereafter
Expand Down
5 changes: 5 additions & 0 deletions config/log.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
'use strict'

/**
* Config values used by our logger
* @module LogConfig
*/

const config = {
// Credit to https://stackoverflow.com/a/323546/6117745 for how to handle
// converting the env var to a boolean
Expand Down
5 changes: 5 additions & 0 deletions config/server.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
'use strict'

/**
* Config values used by this service, for example, the port to use
* @module ServerConfig
*/

const config = {
environment: process.env.NODE_ENV || 'development',
hapi: {
Expand Down
5 changes: 5 additions & 0 deletions config/services.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
'use strict'

/**
* Config values used to connect to our other services
* @module ServicesConfig
*/

const config = {
addressFacade: {
url: process.env.EA_ADDRESS_FACADE_URL
Expand Down
Loading