From 43e8d0ce8c0336ffa72e3ebc6ef0e1be2a204141 Mon Sep 17 00:00:00 2001 From: Mike Keen Date: Sun, 5 Dec 2021 21:22:20 +0000 Subject: [PATCH 1/3] cleanup: models --- models/cobenefit.js | 28 ------ models/index.js | 37 ------- models/party.js | 29 ------ models/project.js | 47 --------- models/projectlocation.js | 29 ------ models/projectrating.js | 31 ------ models/qualification.js | 35 ------- models/relatedproject.js | 30 ------ models/unit.js | 40 -------- models/vintage.js | 32 ------- src/models/co-benefits/co-benefits.model.js | 32 ++++++- src/models/locations/locations.model.js | 33 ++++++- src/models/projects/projects.model.js | 69 +++++++------ .../qualifications/qualifications.model.js | 20 +++- src/models/ratings/ratings.model.js | 35 ++++++- .../related-projects.model.js | 34 ++++++- src/models/units/units.model.js | 96 +++++++------------ src/models/vintages/vintages.model.js | 36 ++++++- 18 files changed, 239 insertions(+), 454 deletions(-) delete mode 100644 models/cobenefit.js delete mode 100644 models/index.js delete mode 100644 models/party.js delete mode 100644 models/project.js delete mode 100644 models/projectlocation.js delete mode 100644 models/projectrating.js delete mode 100644 models/qualification.js delete mode 100644 models/relatedproject.js delete mode 100644 models/unit.js delete mode 100644 models/vintage.js diff --git a/models/cobenefit.js b/models/cobenefit.js deleted file mode 100644 index 5c749a29..00000000 --- a/models/cobenefit.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; -const { - Model -} = require('sequelize'); -module.exports = (sequelize, DataTypes) => { - class CoBenefit extends Model { - /** - * Helper method for defining associations. - * This method is not a part of Sequelize lifecycle. - * The `models/index` file will call this method automatically. - */ - static associate(models) { - // define association here - } - }; - CoBenefit.init({ - id: Sequelize.INTEGER, - benefit: Sequelize.STRING, - owner: Sequelize.STRING, - projectId: Sequelize.NUMBER, - createdAt: Sequelize.DATE, - updatedAt: Sequelize.DATE, - }, { - sequelize, - modelName: 'CoBenefit', - }); - return CoBenefit; -}; \ No newline at end of file diff --git a/models/index.js b/models/index.js deleted file mode 100644 index 33f09e77..00000000 --- a/models/index.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const Sequelize = require('sequelize'); -const basename = path.basename(__filename); -const env = process.env.NODE_ENV || 'development'; -const config = require(__dirname + '/../config/config.json')[env]; -const db = {}; - -let sequelize; -if (config.use_env_variable) { - sequelize = new Sequelize(process.env[config.use_env_variable], config); -} else { - sequelize = new Sequelize(config.database, config.username, config.password, config); -} - -fs - .readdirSync(__dirname) - .filter(file => { - return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js'); - }) - .forEach(file => { - const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes); - db[model.name] = model; - }); - -Object.keys(db).forEach(modelName => { - if (db[modelName].associate) { - db[modelName].associate(db); - } -}); - -db.sequelize = sequelize; -db.Sequelize = Sequelize; - -module.exports = db; diff --git a/models/party.js b/models/party.js deleted file mode 100644 index 2816452c..00000000 --- a/models/party.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; -const { - Model -} = require('sequelize'); -module.exports = (sequelize, DataTypes) => { - class Party extends Model { - /** - * Helper method for defining associations. - * This method is not a part of Sequelize lifecycle. - * The `models/index` file will call this method automatically. - */ - static associate(models) { - // define association here - } - }; - Party.init({ - id: Sequelize.INTEGER, - name: Sequelize.STRING, - country: Sequelize.STRING, - registry: Sequelize.STRING, - owner: Sequelize.STRING, - createdAt: Sequelize.DATE, - updatedAt: Sequelize.DATE, - }, { - sequelize, - modelName: 'Party', - }); - return Party; -}; \ No newline at end of file diff --git a/models/project.js b/models/project.js deleted file mode 100644 index f4131bf0..00000000 --- a/models/project.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; -const { - Model -} = require('sequelize'); -module.exports = (sequelize, DataTypes) => { - class Project extends Model { - /** - * Helper method for defining associations. - * This method is not a part of Sequelize lifecycle. - * The `models/index` file will call this method automatically. - */ - static associate(models) { - // define association here - } - }; - Project.init({ - id: Sequelize.INTEGER, - currentRegistry: Sequelize.STRING, - registryOfOrigin: Sequelize.STRING, - originProjectId: Sequelize.NUMBER, - program: Sequelize.STRING, - warehouseProjectId: Sequelize.NUMBER, - projectName: Sequelize.STRING, - projectLink: Sequelize.STRING, - projectDeveloper: Sequelize.STRING, - sector: Sequelize.STRING, - projectType: Sequelize.STRING, - coveredByNDC: Sequelize.STRING, - NDCLinkage: Sequelize.STRING, - projectStatus: Sequelize.STRING, - projectStatusDate: Sequelize.DATE, - unitMetric: Sequelize.STRING, - methodology: Sequelize.STRING, - methodologyVersion: Sequelize.STRING, - validationApproach: Sequelize.STRING, - validationDate: Sequelize.DATE, - projectTag: Sequelize.STRING, - estimatedAnnualAverageEmmisionReduction: Sequelize.STRING, - owner: Sequelize.STRING, - createdAt: Sequelize.DATE, - updatedAt: Sequelize.DATE, - }, { - sequelize, - modelName: 'Project', - }); - return Project; -}; \ No newline at end of file diff --git a/models/projectlocation.js b/models/projectlocation.js deleted file mode 100644 index 92bc9158..00000000 --- a/models/projectlocation.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; -const { - Model -} = require('sequelize'); -module.exports = (sequelize, DataTypes) => { - class ProjectLocation extends Model { - /** - * Helper method for defining associations. - * This method is not a part of Sequelize lifecycle. - * The `models/index` file will call this method automatically. - */ - static associate(models) { - // define association here - } - }; - ProjectLocation.init({ - id: Sequelize.INTEGER, - countryRegion: Sequelize.STRING, - country: Sequelize.STRING, - owner: Sequelize.STRING, - projectId: Sequelize.NUMBER, - createdAt: Sequelize.DATE, - updatedAt: Sequelize.DATE, - }, { - sequelize, - modelName: 'ProjectLocation', - }); - return ProjectLocation; -}; \ No newline at end of file diff --git a/models/projectrating.js b/models/projectrating.js deleted file mode 100644 index 0e0d94f3..00000000 --- a/models/projectrating.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; -const { - Model -} = require('sequelize'); -module.exports = (sequelize, DataTypes) => { - class ProjectRating extends Model { - /** - * Helper method for defining associations. - * This method is not a part of Sequelize lifecycle. - * The `models/index` file will call this method automatically. - */ - static associate(models) { - // define association here - } - }; - ProjectRating.init({ - id: Sequelize.INTEGER, - ratingType: Sequelize.STRING, - rating: Sequelize.NUMBER, - link: Sequelize.STRING, - scale: Sequelize.STRING, - owner: Sequelize.STRING, - projectId: Sequelize.NUMBER, - createdAt: Sequelize.DATE, - updatedAt: Sequelize.DATE, - }, { - sequelize, - modelName: 'ProjectRating', - }); - return ProjectRating; -}; \ No newline at end of file diff --git a/models/qualification.js b/models/qualification.js deleted file mode 100644 index 1066a928..00000000 --- a/models/qualification.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; -const { - Model -} = require('sequelize'); -module.exports = (sequelize, DataTypes) => { - class Qualification extends Model { - /** - * Helper method for defining associations. - * This method is not a part of Sequelize lifecycle. - * The `models/index` file will call this method automatically. - */ - static associate(models) { - // define association here - } - }; - Qualification.init({ - id: Sequelize.INTEGER, - projectId: Sequelize.NUMBER, - type: Sequelize.STRING, - label: Sequelize.STRING, - creditingPeriodStartDate: Sequelize.DATE, - creditingPeriodEndDate: Sequelize.DATE, - validityStartDate: Sequelize.DATE, - validityEndDate: Sequelize.DATE, - unitQuantity: Sequelize.NUMBER, - owner: Sequelize.STRING, - unitId: Sequelize.NUMBER, - createdAt: Sequelize.DATE, - updatedAt: Sequelize.DATE, - }, { - sequelize, - modelName: 'Qualification', - }); - return Qualification; -}; \ No newline at end of file diff --git a/models/relatedproject.js b/models/relatedproject.js deleted file mode 100644 index 2e92efc6..00000000 --- a/models/relatedproject.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; -const { - Model -} = require('sequelize'); -module.exports = (sequelize, DataTypes) => { - class RelatedProject extends Model { - /** - * Helper method for defining associations. - * This method is not a part of Sequelize lifecycle. - * The `models/index` file will call this method automatically. - */ - static associate(models) { - // define association here - } - }; - RelatedProject.init({ - id: Sequelize.INTEGER, - relatedProjectType: Sequelize.STRING, - registry: Sequelize.STRING, - note: Sequelize.STRING, - owner: Sequelize.STRING, - projectId: Sequelize.NUMBER, - createdAt: Sequelize.DATE, - updatedAt: Sequelize.DATE - }, { - sequelize, - modelName: 'RelatedProject', - }); - return RelatedProject; -}; \ No newline at end of file diff --git a/models/unit.js b/models/unit.js deleted file mode 100644 index a3710bbd..00000000 --- a/models/unit.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; -const { - Model -} = require('sequelize'); -module.exports = (sequelize, DataTypes) => { - class Unit extends Model { - /** - * Helper method for defining associations. - * This method is not a part of Sequelize lifecycle. - * The `models/index` file will call this method automatically. - */ - static associate(models) { - // define association here - } - }; - Unit.init({ - id: Sequelize.INTEGER, - owner: Sequelize.STRING, - buyer: Sequelize.STRING, - registry: Sequelize.STRING, - blockIdentifier: Sequelize.STRING, - identifier: Sequelize.STRING, - qualificationId: Sequelize.NUMBER, - unitType: Sequelize.STRING, - unitCount: Sequelize.NUMBER, - unitStatus: Sequelize.STRING, - unitStatusDate: Sequelize.DATE, - transactionType: Sequelize.STRING, - unitIssuanceLocation: Sequelize.STRING, - unitLink: Sequelize.STRING, - correspondingAdjustment: Sequelize.STRING, - unitTag: Sequelize.STRING, - vintageId: Sequelize.NUMBER, - createdAt: Sequelize.DATE, - updatedAt: Sequelize.DATE}, { - sequelize, - modelName: 'Unit', - }); - return Unit; -}; \ No newline at end of file diff --git a/models/vintage.js b/models/vintage.js deleted file mode 100644 index e43a2a21..00000000 --- a/models/vintage.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; -const { - Model -} = require('sequelize'); -module.exports = (sequelize, DataTypes) => { - class Vintage extends Model { - /** - * Helper method for defining associations. - * This method is not a part of Sequelize lifecycle. - * The `models/index` file will call this method automatically. - */ - static associate(models) { - // define association here - } - }; - Vintage.init({ - id: Sequelize.INTEGER, - startDate: Sequelize.DATE, - endDate: Sequelize.DATE, - verificationApproach: Sequelize.STRING, - verificationDate: Sequelize.DATE, - verificationBody: Sequelize.STRING, - owner: Sequelize.STRING, - projectId: Sequelize.NUMBER, - createdAt: Sequelize.DATE, - updatedAt: Sequelize.DATE, - }, { - sequelize, - modelName: 'Vintage', - }); - return Vintage; -}; \ No newline at end of file diff --git a/src/models/co-benefits/co-benefits.model.js b/src/models/co-benefits/co-benefits.model.js index 46f29a48..fc1e2c56 100644 --- a/src/models/co-benefits/co-benefits.model.js +++ b/src/models/co-benefits/co-benefits.model.js @@ -1,9 +1,33 @@ 'use strict'; +import Sequelize from 'sequelize'; +const { DataTypes, Model } = Sequelize; +import { sequelize } from '../database'; -class CoBenefits { - static list(page = 0, limit = 10) { - return stub; +class CoBenefit extends Model { + /** + * Helper method for defining associations. + * This method is not a part of Sequelize lifecycle. + * The `models/index` file will call this method automatically. + */ + static associate(models) { + // define association here } + } -export { CoBenefits }; +CoBenefit.init({ + id: { + type: Sequelize.NUMBER, + primaryKey: true, + }, + benefit: Sequelize.STRING, + owner: Sequelize.STRING, + projectId: Sequelize.NUMBER, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE, +}, { + sequelize, + modelName: 'CoBenefits', +}); + +export { CoBenefit }; \ No newline at end of file diff --git a/src/models/locations/locations.model.js b/src/models/locations/locations.model.js index 34fd83fb..a9e82198 100644 --- a/src/models/locations/locations.model.js +++ b/src/models/locations/locations.model.js @@ -1,9 +1,34 @@ 'use strict'; +import Sequelize from 'sequelize'; +const { DataTypes, Model } = Sequelize; +import { sequelize } from '../database'; -class Location { - static list(page = 0, limit = 10) { - return stub; +class ProjectLocation extends Model { + /** + * Helper method for defining associations. + * This method is not a part of Sequelize lifecycle. + * The `models/index` file will call this method automatically. + */ + static associate(models) { + // define association here } + } -export { Location }; +ProjectLocation.init({ + id: { + type: Sequelize.NUMBER, + primaryKey: true, + }, + countryRegion: Sequelize.STRING, + country: Sequelize.STRING, + owner: Sequelize.STRING, + projectId: Sequelize.NUMBER, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE, +}, { + sequelize, + modelName: 'ProjectLocations', +}); + +export { ProjectLocation }; diff --git a/src/models/projects/projects.model.js b/src/models/projects/projects.model.js index 2376f256..23b42ebf 100644 --- a/src/models/projects/projects.model.js +++ b/src/models/projects/projects.model.js @@ -3,36 +3,47 @@ import Sequelize from 'sequelize'; const { DataTypes, Model } = Sequelize; import { sequelize } from '../database'; -class Project extends Model {} +class Project extends Model { + /** + * Helper method for defining associations. + * This method is not a part of Sequelize lifecycle. + * The `models/index` file will call this method automatically. + */ + static associate(models) { + // define association here + } -Project.init( - { - id: { - type: Sequelize.UUID, - defaultValue: Sequelize.UUIDV1, - primaryKey: true, - }, - id_origin: DataTypes.STRING, - warehouse_project_id: DataTypes.STRING, - registry_current: DataTypes.STRING, - registry_origin: DataTypes.STRING, - name: DataTypes.STRING, - link: DataTypes.STRING, - developer: DataTypes.STRING, - sector: DataTypes.STRING, - type: DataTypes.STRING, - ndc_covered: DataTypes.BOOLEAN, - ndc_linkage: DataTypes.STRING, - status: DataTypes.STRING, - status_date: DataTypes.STRING, - unit_metric: DataTypes.STRING, - methodology: DataTypes.STRING, - methodology_version: DataTypes.STRING, - validation_approach: DataTypes.STRING, - validation_date: DataTypes.STRING, - estimated_annual_average_emission_reduction: DataTypes.STRING, +} + +Project.init({ + id: { + type: Sequelize.NUMBER, + primaryKey: true, }, - { sequelize, modelName: 'project' }, -); + currentRegistry: Sequelize.STRING, + registryOfOrigin: Sequelize.STRING, + originProjectId: Sequelize.NUMBER, + program: Sequelize.STRING, + warehouseProjectId: Sequelize.NUMBER, + projectName: Sequelize.STRING, + projectLink: Sequelize.STRING, + projectDeveloper: Sequelize.STRING, + sector: Sequelize.STRING, + projectType: Sequelize.STRING, + coveredByNDC: Sequelize.STRING, + NDCLinkage: Sequelize.STRING, + projectStatus: Sequelize.STRING, + projectStatusDate: Sequelize.DATE, + unitMetric: Sequelize.STRING, + methodology: Sequelize.STRING, + methodologyVersion: Sequelize.STRING, + validationApproach: Sequelize.STRING, + validationDate: Sequelize.DATE, + projectTag: Sequelize.STRING, + estimatedAnnualAverageEmmisionReduction: Sequelize.STRING, + owner: Sequelize.STRING, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE, +}, { sequelize, modelName: 'Projects' }); export { Project }; diff --git a/src/models/qualifications/qualifications.model.js b/src/models/qualifications/qualifications.model.js index a3b77f6b..a31a719f 100644 --- a/src/models/qualifications/qualifications.model.js +++ b/src/models/qualifications/qualifications.model.js @@ -3,14 +3,24 @@ import Sequelize from 'sequelize'; const { DataTypes, Model } = Sequelize; import { sequelize } from '../database'; -class Qualification extends Model { } +class Qualification extends Model { + /** + * Helper method for defining associations. + * This method is not a part of Sequelize lifecycle. + * The `models/index` file will call this method automatically. + */ + static associate(models) { + // define association here + } + +} Qualification.init({ id: { allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER }, qualificationLink: { type: Sequelize.STRING @@ -44,6 +54,6 @@ Qualification.init({ allowNull: false, type: Sequelize.DATE } -}, { sequelize, modelName: 'qualification' }); +}, { sequelize, modelName: 'Qualifications' }); export { Qualification }; diff --git a/src/models/ratings/ratings.model.js b/src/models/ratings/ratings.model.js index ff2cee76..3d913bf6 100644 --- a/src/models/ratings/ratings.model.js +++ b/src/models/ratings/ratings.model.js @@ -1,9 +1,36 @@ 'use strict'; +import Sequelize from 'sequelize'; +const { DataTypes, Model } = Sequelize; +import { sequelize } from '../database'; -class Rating { - static list(page = 0, limit = 10) { - return stub; +class Rating extends Model { + /** + * Helper method for defining associations. + * This method is not a part of Sequelize lifecycle. + * The `models/index` file will call this method automatically. + */ + static associate(models) { + // define association here } + } -export { Rating }; +Rating.init({ + id: { + type: Sequelize.NUMBER, + primaryKey: true, + }, + ratingType: Sequelize.STRING, + rating: Sequelize.NUMBER, + link: Sequelize.STRING, + scale: Sequelize.STRING, + owner: Sequelize.STRING, + projectId: Sequelize.NUMBER, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE, +}, { + sequelize, + modelName: 'ProjectRatings', +}); + +export { Rating }; \ No newline at end of file diff --git a/src/models/related-projects/related-projects.model.js b/src/models/related-projects/related-projects.model.js index 20a7c264..b4a477bd 100644 --- a/src/models/related-projects/related-projects.model.js +++ b/src/models/related-projects/related-projects.model.js @@ -1,9 +1,35 @@ 'use strict'; +import Sequelize from 'sequelize'; +const { DataTypes, Model } = Sequelize; +import { sequelize } from '../database'; -class RelatedProject { - static list(page = 0, limit = 10) { - return stub; +class RelatedProject extends Model { + /** + * Helper method for defining associations. + * This method is not a part of Sequelize lifecycle. + * The `models/index` file will call this method automatically. + */ + static associate(models) { + // define association here } + } -export { RelatedProject }; +RelatedProject.init({ + id: { + type: Sequelize.NUMBER, + primaryKey: true, + }, + relatedProjectType: Sequelize.STRING, + registry: Sequelize.STRING, + note: Sequelize.STRING, + owner: Sequelize.STRING, + projectId: Sequelize.NUMBER, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE +}, { + sequelize, + modelName: 'RelatedProjects', +}); + +export { RelatedProject }; \ No newline at end of file diff --git a/src/models/units/units.model.js b/src/models/units/units.model.js index a83b7727..baa40591 100644 --- a/src/models/units/units.model.js +++ b/src/models/units/units.model.js @@ -3,71 +3,43 @@ import Sequelize from 'sequelize'; const { DataTypes, Model } = Sequelize; import { sequelize } from '../database'; -class Unit extends Model { } +class Unit extends Model { + /** + * Helper method for defining associations. + * This method is not a part of Sequelize lifecycle. + * The `models/index` file will call this method automatically. + */ + static associate(models) { + // define association here + } + +} Unit.init({ id: { - allowNull: false, - autoIncrement: true, + type: Sequelize.NUMBER, primaryKey: true, - type: Sequelize.INTEGER - }, - buyer: { - type: Sequelize.STRING - }, - registry: { - type: Sequelize.STRING - }, - blockIdentifier: { - type: Sequelize.STRING - }, - identifier: { - type: Sequelize.STRING - }, - unitType: { - type: Sequelize.STRING - }, - unitCount: { - type: Sequelize.NUMBER - }, - unitStatus: { - type: Sequelize.STRING - }, - unitStatusDate: { - type: Sequelize.DATE }, - transactionType: { - type: Sequelize.STRING - }, - unitIssuanceLocation: { - type: Sequelize.STRING - }, - unitLink: { - type: Sequelize.STRING - }, - correspondingAdjustment: { - type: Sequelize.STRING - }, - unitTag: { - type: Sequelize.STRING - }, - vintageId: { - type: Sequelize.NUMBER - }, - qualificationId: { - type: Sequelize.NUMBER - }, - owner: { - type: Sequelize.STRING - }, - createdAt: { - allowNull: false, - type: Sequelize.DATE - }, - updatedAt: { - allowNull: false, - type: Sequelize.DATE - } -}, { sequelize, modelName: 'qualification' }); + owner: Sequelize.STRING, + buyer: Sequelize.STRING, + registry: Sequelize.STRING, + blockIdentifier: Sequelize.STRING, + identifier: Sequelize.STRING, + qualificationId: Sequelize.NUMBER, + unitType: Sequelize.STRING, + unitCount: Sequelize.NUMBER, + unitStatus: Sequelize.STRING, + unitStatusDate: Sequelize.DATE, + transactionType: Sequelize.STRING, + unitIssuanceLocation: Sequelize.STRING, + unitLink: Sequelize.STRING, + correspondingAdjustment: Sequelize.STRING, + unitTag: Sequelize.STRING, + vintageId: Sequelize.NUMBER, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE}, { + sequelize, + modelName: 'Units', +}); -export { Unit }; +export { Unit }; \ No newline at end of file diff --git a/src/models/vintages/vintages.model.js b/src/models/vintages/vintages.model.js index a21ed654..6f27bea7 100644 --- a/src/models/vintages/vintages.model.js +++ b/src/models/vintages/vintages.model.js @@ -1,9 +1,37 @@ 'use strict'; +import Sequelize from 'sequelize'; +const { DataTypes, Model } = Sequelize; +import { sequelize } from '../database'; -class VintageModel { - static list(page = 0, limit = 10) { - return stub; +class Vintage extends Model { + /** + * Helper method for defining associations. + * This method is not a part of Sequelize lifecycle. + * The `models/index` file will call this method automatically. + */ + static associate(models) { + // define association here } + } -export { VintageModel }; +Vintage.init({ + id: { + type: Sequelize.NUMBER, + primaryKey: true, + }, + startDate: Sequelize.DATE, + endDate: Sequelize.DATE, + verificationApproach: Sequelize.STRING, + verificationDate: Sequelize.DATE, + verificationBody: Sequelize.STRING, + owner: Sequelize.STRING, + projectId: Sequelize.NUMBER, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE, +}, { + sequelize, + modelName: 'Vintages', +}); + +export { Vintage }; From 1693e8f58d1ea4771c00381cf160b3c5c3196495 Mon Sep 17 00:00:00 2001 From: Mike Keen Date: Sun, 5 Dec 2021 21:23:44 +0000 Subject: [PATCH 2/3] cleanup: tests --- .../co-benefit.spec.js} | 14 ++++----- tests/resources/locations.spec.js | 30 +++++++++++++++++++ tests/resources/ratings.spec.js | 30 +++++++++++++++++++ tests/resources/related-projects.spec.js | 30 +++++++++++++++++++ tests/resources/vintages.spec.js | 30 +++++++++++++++++++ 5 files changed, 127 insertions(+), 7 deletions(-) rename tests/{routes/qualifications.spec.js => resources/co-benefit.spec.js} (58%) create mode 100644 tests/resources/locations.spec.js create mode 100644 tests/resources/ratings.spec.js create mode 100644 tests/resources/related-projects.spec.js create mode 100644 tests/resources/vintages.spec.js diff --git a/tests/routes/qualifications.spec.js b/tests/resources/co-benefit.spec.js similarity index 58% rename from tests/routes/qualifications.spec.js rename to tests/resources/co-benefit.spec.js index a425a690..64ef1726 100644 --- a/tests/routes/qualifications.spec.js +++ b/tests/resources/co-benefit.spec.js @@ -6,21 +6,21 @@ import app from '../../src/server'; chai.use(chaiHttp); chai.should(); -describe('Qualifications Routes', () => { - describe('GET /v1/qualifications/', () => { - it('should get all qualifications', () => { +describe('Co-Benefits Routes', () => { + describe('GET /v1/co-benefits/', () => { + it('should get all co-benefits', () => { chai.request(app) - .get('/v1/qualifications/?useMock=true') + .get('/v1/co-benefits/?useMock=true') .end((err, res) => { res.should.have.status(200); res.body.should.be.a('array'); }); }); }); - describe('GET /v1/qualifications/?id=1', () => { - it('should get a single qualification', () => { + describe('GET /v1/co-benefits/?id=1', () => { + it('should get a single co-benefit', () => { chai.request(app) - .get('/v1/qualifications/?useMock=true&id=1') + .get('/v1/co-benefits/?useMock=true&id=1') .end((err, res) => { res.should.have.status(200); res.body.should.be.a('object'); diff --git a/tests/resources/locations.spec.js b/tests/resources/locations.spec.js new file mode 100644 index 00000000..d8ba75b5 --- /dev/null +++ b/tests/resources/locations.spec.js @@ -0,0 +1,30 @@ +import chai from 'chai'; +import chaiHttp from 'chai-http'; +import app from '../../src/server'; + +// Configure chai +chai.use(chaiHttp); +chai.should(); + +describe('Locations Routes', () => { + describe('GET /v1/locations/', () => { + it('should get all locations', () => { + chai.request(app) + .get('/v1/locations/?useMock=true') + .end((err, res) => { + res.should.have.status(200); + res.body.should.be.a('array'); + }); + }); + }); + describe('GET /v1/locations/?id=1', () => { + it('should get a single location', () => { + chai.request(app) + .get('/v1/locations/?useMock=true&id=1') + .end((err, res) => { + res.should.have.status(200); + res.body.should.be.a('object'); + }); + }); + }); +}); diff --git a/tests/resources/ratings.spec.js b/tests/resources/ratings.spec.js new file mode 100644 index 00000000..0cbcdcb9 --- /dev/null +++ b/tests/resources/ratings.spec.js @@ -0,0 +1,30 @@ +import chai from 'chai'; +import chaiHttp from 'chai-http'; +import app from '../../src/server'; + +// Configure chai +chai.use(chaiHttp); +chai.should(); + +describe('Ratings Routes', () => { + describe('GET /v1/ratings/', () => { + it('should get all ratings', () => { + chai.request(app) + .get('/v1/ratings/?useMock=true') + .end((err, res) => { + res.should.have.status(200); + res.body.should.be.a('array'); + }); + }); + }); + describe('GET /v1/ratings/?id=1', () => { + it('should get a single rating', () => { + chai.request(app) + .get('/v1/ratings/?useMock=true&id=1') + .end((err, res) => { + res.should.have.status(200); + res.body.should.be.a('object'); + }); + }); + }); +}); diff --git a/tests/resources/related-projects.spec.js b/tests/resources/related-projects.spec.js new file mode 100644 index 00000000..400425a6 --- /dev/null +++ b/tests/resources/related-projects.spec.js @@ -0,0 +1,30 @@ +import chai from 'chai'; +import chaiHttp from 'chai-http'; +import app from '../../src/server'; + +// Configure chai +chai.use(chaiHttp); +chai.should(); + +describe('Related Projects Routes', () => { + describe('GET /v1/related-projects/', () => { + it('should get all related projects', () => { + chai.request(app) + .get('/v1/related-projects/?useMock=true') + .end((err, res) => { + res.should.have.status(200); + res.body.should.be.a('array'); + }); + }); + }); + describe('GET /v1/related-projects/?id=1', () => { + it('should get a single related project', () => { + chai.request(app) + .get('/v1/related-projects/?useMock=true&id=1') + .end((err, res) => { + res.should.have.status(200); + res.body.should.be.a('object'); + }); + }); + }); +}); diff --git a/tests/resources/vintages.spec.js b/tests/resources/vintages.spec.js new file mode 100644 index 00000000..9f89fca3 --- /dev/null +++ b/tests/resources/vintages.spec.js @@ -0,0 +1,30 @@ +import chai from 'chai'; +import chaiHttp from 'chai-http'; +import app from '../../src/server'; + +// Configure chai +chai.use(chaiHttp); +chai.should(); + +describe('Vintages Routes', () => { + describe('GET /v1/vintages/', () => { + it('should get all vintages', () => { + chai.request(app) + .get('/v1/vintages/?useMock=true') + .end((err, res) => { + res.should.have.status(200); + res.body.should.be.a('array'); + }); + }); + }); + describe('GET /v1/vintages/?id=1', () => { + it('should get a single vintage', () => { + chai.request(app) + .get('/v1/vintages/?useMock=true&id=1') + .end((err, res) => { + res.should.have.status(200); + res.body.should.be.a('object'); + }); + }); + }); +}); From e282581daee5323d2e243fa333f42061fc32b6a5 Mon Sep 17 00:00:00 2001 From: Mike Keen Date: Sun, 5 Dec 2021 21:27:31 +0000 Subject: [PATCH 3/3] feat: qualifications tests --- tests/resources/qualifications.spec.js | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/resources/qualifications.spec.js diff --git a/tests/resources/qualifications.spec.js b/tests/resources/qualifications.spec.js new file mode 100644 index 00000000..a425a690 --- /dev/null +++ b/tests/resources/qualifications.spec.js @@ -0,0 +1,30 @@ +import chai from 'chai'; +import chaiHttp from 'chai-http'; +import app from '../../src/server'; + +// Configure chai +chai.use(chaiHttp); +chai.should(); + +describe('Qualifications Routes', () => { + describe('GET /v1/qualifications/', () => { + it('should get all qualifications', () => { + chai.request(app) + .get('/v1/qualifications/?useMock=true') + .end((err, res) => { + res.should.have.status(200); + res.body.should.be.a('array'); + }); + }); + }); + describe('GET /v1/qualifications/?id=1', () => { + it('should get a single qualification', () => { + chai.request(app) + .get('/v1/qualifications/?useMock=true&id=1') + .end((err, res) => { + res.should.have.status(200); + res.body.should.be.a('object'); + }); + }); + }); +});