Skip to content

Commit

Permalink
chore: Remove STIGMAN_DB_TYPE configuration option (NUWCDIVNPT#1157)
Browse files Browse the repository at this point in the history
* remove STIGMAN_DB_TYPE configuration option

* move services up one level, remove mysql directory

* remove remaining /mysql paths
  • Loading branch information
cd-rite authored Dec 6, 2023
1 parent 76b6048 commit 8a69ec2
Show file tree
Hide file tree
Showing 64 changed files with 33 additions and 54 deletions.
9 changes: 0 additions & 9 deletions api/launchers/stig-manager.bat
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,6 @@
::==============================================================================
:: set STIGMAN_DB_TLS_KEY_FILE=

::==============================================================================
:: STIGMAN_DB_TYPE
::
:: | Default: "mysql" | The database type. Valid values are "mysql"
::
:: Affects: API
::==============================================================================
:: set STIGMAN_DB_TYPE=

::==============================================================================
:: STIGMAN_DB_USER
::
Expand Down
9 changes: 0 additions & 9 deletions api/launchers/stig-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,6 @@
#==============================================================================
# export STIGMAN_DB_TLS_KEY_FILE=

#==============================================================================
# STIGMAN_DB_TYPE
#
# | Default: "mysql" | The database type. Valid values are "mysql"
#
# Affects: API
#==============================================================================
# export STIGMAN_DB_TYPE=

#==============================================================================
# STIGMAN_DB_USER
#
Expand Down
6 changes: 3 additions & 3 deletions api/source/controllers/Asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
const writer = require('../utils/writer');
const config = require('../utils/config')
const escape = require('../utils/escape')
const AssetService = require(`../service/${config.database.type}/AssetService`);
const CollectionService = require(`../service/${config.database.type}/CollectionService`);
const dbUtils = require(`../service/${config.database.type}/utils`)
const AssetService = require(`../service/AssetService`);
const CollectionService = require(`../service/CollectionService`);
const dbUtils = require(`../service/utils`)
const {XMLBuilder} = require("fast-xml-parser")
const SmError = require('../utils/error')
const {escapeForXml} = require('../utils/escape')
Expand Down
6 changes: 3 additions & 3 deletions api/source/controllers/Collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
const writer = require('../utils/writer')
const config = require('../utils/config')
const escape = require('../utils/escape')
const CollectionService = require(`../service/${config.database.type}/CollectionService`)
const AssetService = require(`../service/${config.database.type}/AssetService`)
const STIGService = require(`../service/${config.database.type}/STIGService`)
const CollectionService = require(`../service/CollectionService`)
const AssetService = require(`../service/AssetService`)
const STIGService = require(`../service/STIGService`)
const Serialize = require(`../utils/serializers`)
const Security = require('../utils/accessLevels')
const SmError = require('../utils/error')
Expand Down
2 changes: 1 addition & 1 deletion api/source/controllers/Metrics.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const config = require('../utils/config')
const MetricsService = require(`../service/${config.database.type}/MetricsService`)
const MetricsService = require(`../service/MetricsService`)
const Collection = require('./Collection')
const Security = require('../utils/accessLevels')
const SmError = require('../utils/error')
Expand Down
2 changes: 1 addition & 1 deletion api/source/controllers/Operation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const writer = require('../utils/writer.js')
const config = require('../utils/config')
const OperationService = require(`../service/${config.database.type}/OperationService`)
const OperationService = require(`../service/OperationService`)
const Asset = require(`./Asset`)
const Collection = require(`./Collection`)
const User = require(`./User`)
Expand Down
4 changes: 2 additions & 2 deletions api/source/controllers/Review.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

const config = require('../utils/config')
const ReviewService = require(`../service/${config.database.type}/ReviewService`)
const CollectionService = require(`../service/${config.database.type}/CollectionService`)
const ReviewService = require(`../service/ReviewService`)
const CollectionService = require(`../service/CollectionService`)
const Collection = require(`./Collection`)
const SmError = require('../utils/error')
const Security = require('../utils/accessLevels')
Expand Down
2 changes: 1 addition & 1 deletion api/source/controllers/STIG.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const config = require('../utils/config');
const SmError = require('../utils/error');
const parsers = require('../utils/parsers.js')
const STIGService = require(`../service/${config.database.type}/STIGService`)
const STIGService = require(`../service/STIGService`)

module.exports.importBenchmark = async function importManualBenchmark (req, res, next) {
try {
Expand Down
6 changes: 3 additions & 3 deletions api/source/controllers/User.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

const config = require('../utils/config')
const UserService = require(`../service/${config.database.type}/UserService`)
const AssetService = require(`../service/${config.database.type}/AssetService`)
const CollectionService = require(`../service/${config.database.type}/CollectionService`)
const UserService = require(`../service/UserService`)
const AssetService = require(`../service/AssetService`)
const CollectionService = require(`../service/CollectionService`)
const SmError = require('../utils/error')
/* */
module.exports.createUser = async function createUser (req, res, next) {
Expand Down
4 changes: 2 additions & 2 deletions api/source/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const jsyaml = require('js-yaml');
const fs = require('fs')
const multer = require('multer')
const writer = require('./utils/writer.js')
const OperationSvc = require(`./service/${config.database.type}/OperationService`)
const OperationSvc = require(`./service/OperationService`)
const { middleware: openApiMiddleware, resolvers } = require('express-openapi-validator')

// express-openapi-validator does not expose top-level HttpError in their index.js.
Expand Down Expand Up @@ -224,7 +224,7 @@ const STIGMAN = {
}

async function startServer(app) {
let db = require(`./service/${config.database.type}/utils`)
let db = require(`./service/utils`)
let isNewDb
try {
let authReturn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
const dbUtils = require('./utils')
const config = require('../../utils/config')
const config = require('../utils/config')
const uuid = require('uuid')

let _this = this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
const dbUtils = require('./utils')
const config = require('../../utils/config.js')
const MyController = require('../../controllers/Collection')
const config = require('../utils/config.js')
const MyController = require('../controllers/Collection')

const _this = this

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
const dbUtils = require('./utils')
const config = require('../../utils/config')
const config = require('../utils/config')


/**
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const config = require('../../utils/config')
const config = require('../utils/config')
const dbUtils = require('./utils')

const _this = this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Importer = require('./lib/mysql-import.js')
const logger = require('../../../utils/logger')
const logger = require('../../utils/logger')
const path = require('path')
const fs = require('fs')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Importer = require('./lib/mysql-import.js')
const logger = require('../../../utils/logger')
const logger = require('../../utils/logger')
const path = require('path')
const fs = require('fs')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Importer = require('./lib/mysql-import.js')
const logger = require('../../../utils/logger')
const logger = require('../../utils/logger')
const path = require('path')
const fs = require('fs')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Importer = require('./lib/mysql-import.js')
const logger = require('../../../utils/logger')
const logger = require('../../utils/logger')
const path = require('path')
const fs = require('fs')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Importer = require('./lib/mysql-import.js')
const logger = require('../../../utils/logger')
const logger = require('../../utils/logger')
const path = require('path')
const fs = require('fs')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Importer = require('./lib/mysql-import.js')
const logger = require('../../../utils/logger')
const logger = require('../../utils/logger')
const path = require('path')
const fs = require('fs')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Importer = require('./lib/mysql-import.js')
const logger = require('../../../utils/logger')
const logger = require('../../utils/logger')
const path = require('path')
const fs = require('fs')

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const path = require('path')
const logger = require('../../../../utils/logger')
const logger = require('../../../utils/logger')

module.exports = class MigrationHandler {
constructor(upCommands = [], downCommands = []) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @license MIT
*
* Modified to support mysql2 PromisePool
* https://github.com/NUWCDIVNPT/stig-manager/api/source/service/mysql/migrations/lib/mysql-import.js
* https://github.com/NUWCDIVNPT/stig-manager/api/source/service/migrations/lib/mysql-import.js
**/

'use strict';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const mysql = require('mysql2/promise');
const config = require('../../utils/config')
const logger = require('../../utils/logger')
const config = require('../utils/config')
const logger = require('../utils/logger')
const retry = require('async-retry')
const Umzug = require('umzug')
const path = require('path')
Expand Down
2 changes: 1 addition & 1 deletion api/source/utils/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const jwt = require('jsonwebtoken')
const retry = require('async-retry')
const _ = require('lodash')
const {promisify} = require('util')
const User = require(`../service/${config.database.type}/UserService`)
const User = require(`../service/UserService`)
const axios = require('axios')

let jwksUri
Expand Down
1 change: 0 additions & 1 deletion api/source/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ let config = {
maxUpload: process.env.STIGMAN_API_MAX_UPLOAD || "1073741824"
},
database: {
type: process.env.STIGMAN_DB_TYPE || "mysql",
host: process.env.STIGMAN_DB_HOST || "localhost",
port: process.env.STIGMAN_DB_PORT || 3306,
schema: process.env.STIGMAN_DB_SCHEMA || "stigman",
Expand Down
2 changes: 0 additions & 2 deletions docs/installation-and-setup/envvars.csv
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
| A file/path relative to the API /tls directory that contains the PEM encoded Client certificate used when authenticating the database client. Additionally requires setting values for ``STIGMAN_DB_TLS_CA_FILE`` and ``STIGMAN_DB_TLS_KEY_FILE``. ","API "
"STIGMAN_DB_TLS_KEY_FILE","| **No default**
| A file/path relative to the API /tls directory that contains the PEM encoded Client private key used when authenticating the database client. Additionally requires setting values for ``STIGMAN_DB_TLS_CA_FILE`` and ``STIGMAN_DB_TLS_CERT_FILE``.","API "
"STIGMAN_DB_TYPE","| **Default** ``mysql``
| The database type. Valid values are ``mysql`` ","API "
"STIGMAN_DB_USER","| **Default** ``stigman``
| The user account used to login to the database ","API "
"STIGMAN_DOCS_DIRECTORY","| **Default** ``./docs``
Expand Down

0 comments on commit 8a69ec2

Please sign in to comment.