diff --git a/package.json b/package.json index fc01ae7c..1a6140c0 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ "test": "npm run resetTestDb && npx cross-env NODE_ENV=test mocha tests/**/*.spec.js --reporter spec --exit --timeout 30000", "release": "./node_modules/.bin/standard-version && git push --tags", "postinstall": "npm run requirements-check", - "resetdb": "sequelize db:migrate:undo:all --env local && npx sequelize-cli db:migrate --env local && npx sequelize-cli db:seed:all --debug --env local", - "cleandb": "sequelize db:migrate:undo:all --env local && && npx sequelize-cli db:migrate --env local", - "resetTestDb": "sequelize db:migrate:undo:all --env test && npx sequelize-cli db:migrate --env test && npx sequelize-cli db:seed:all --debug --env test && rm -f ./testMirror.sqlite3 && npx sequelize-cli db:migrate --env mirrorTest", + "resetdb": "rm -f ./data.sqlite3 && npx sequelize-cli db:migrate --env local && npx sequelize-cli db:seed:all --debug --env local", + "cleandb": "rm -f ./data.sqlite3 && && npx sequelize-cli db:migrate --env local", + "resetTestDb": "rm -f ./test.sqlite3 && npx sequelize-cli db:migrate --env test && npx sequelize-cli db:seed:all --debug --env test && rm -f ./testMirror.sqlite3 && npx sequelize-cli db:migrate --env mirrorTest", "resetMirrorDb": "npx sequelize-cli db:drop --env mirror && npx sequelize-cli db:create --env mirror && npx sequelize-cli db:migrate --env mirror --debug", "prepare": "husky install" }, diff --git a/src/controllers/index.js b/src/controllers/index.js index 50f53389..23ae20d6 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -2,3 +2,4 @@ export * as ProjectController from './project.controller'; export * as UnitController from './units.controller'; export * as StagingController from './staging.controller'; export * as OrganizationController from './organization.controller'; +export * as VintageController from './vintage.controller'; diff --git a/src/controllers/vintage.controller.js b/src/controllers/vintage.controller.js new file mode 100644 index 00000000..7e9a30c8 --- /dev/null +++ b/src/controllers/vintage.controller.js @@ -0,0 +1,11 @@ +import { Vintage, Organization } from '../models'; + +export const findAll = async (req, res) => { + const homeOrg = await Organization.getHomeOrg(); + console.log({ orgUid: Object.keys(homeOrg)[0] }); + return res.json( + await Vintage.findAll({ + where: { orgUid: Object.keys(homeOrg)[0] }, + }), + ); +}; diff --git a/src/models/vintages/vintages.modeltypes.cjs b/src/models/vintages/vintages.modeltypes.cjs index dae4da8a..510a47f1 100644 --- a/src/models/vintages/vintages.modeltypes.cjs +++ b/src/models/vintages/vintages.modeltypes.cjs @@ -8,6 +8,7 @@ module.exports = { defaultValue: () => uuidv4(), primaryKey: true, }, + orgUid: Sequelize.STRING, startDate: Sequelize.DATE, endDate: Sequelize.DATE, verificationApproach: Sequelize.STRING, diff --git a/src/models/vintages/vintages.stub.json b/src/models/vintages/vintages.stub.json index c2335952..17b9fd2a 100644 --- a/src/models/vintages/vintages.stub.json +++ b/src/models/vintages/vintages.stub.json @@ -1,6 +1,7 @@ [ { "id": "a6745831-5d5e-45ed-b9fe-fd6aa129df25", + "orgUid": "f1c54511-865e-4611-976c-7c3c1f704662", "startDate": "11/21/22", "endDate": "12/2/22", "verificationDate": "11/19/22", @@ -11,6 +12,7 @@ }, { "id": "3d5a8ed2-e5a7-4275-a36e-3456812e39b7", + "orgUid": "f1c54511-865e-4611-976c-7c3c1f704662", "startDate": "3/2/22", "endDate": "5/5/22", "verificationDate": "1/19/22", @@ -21,6 +23,7 @@ }, { "id": "57c1859d-6aa4-4c57-9dfb-6438e0d4653e", + "orgUid": "f1c54511-865e-4611-976c-7c3c1f704662", "startDate": "4/14/22", "endDate": "7/25/22", "verificationDate": "3/8/22", @@ -31,6 +34,7 @@ }, { "id": "74887b22-da3b-4c2b-b945-670319193cdd", + "orgUid": "f1c54511-865e-4611-976c-7c3c1f704662", "startDate": "7/23/22", "endDate": "9/12/22", "verificationDate": "5/4/22", @@ -41,6 +45,7 @@ }, { "id": "7f7f23a5-3e1a-43b4-82d8-b4156b158f88", + "orgUid": "f1c54511-865e-4611-976c-7c3c1f704662", "startDate": "9/13/22", "endDate": "11/21/22", "verificationDate": "8/22/22", diff --git a/src/routes/v1/index.js b/src/routes/v1/index.js index 5f9f00b0..931369be 100644 --- a/src/routes/v1/index.js +++ b/src/routes/v1/index.js @@ -8,11 +8,13 @@ import { UnitRouter, StagingRouter, OrganizationRouter, + VintageRouter, } from './resources'; V1Router.use('/projects', ProjectRouter); V1Router.use('/units', UnitRouter); V1Router.use('/staging', StagingRouter); V1Router.use('/organizations', OrganizationRouter); +V1Router.use('/vintages', VintageRouter); export { V1Router }; diff --git a/src/routes/v1/resources/index.js b/src/routes/v1/resources/index.js index 16dded09..fbf86421 100644 --- a/src/routes/v1/resources/index.js +++ b/src/routes/v1/resources/index.js @@ -2,3 +2,4 @@ export * from './projects'; export * from './units'; export * from './staging'; export * from './organization'; +export * from './vintages'; diff --git a/src/routes/v1/resources/vintages.js b/src/routes/v1/resources/vintages.js new file mode 100644 index 00000000..2007f7ee --- /dev/null +++ b/src/routes/v1/resources/vintages.js @@ -0,0 +1,13 @@ +'use strict'; + +import express from 'express'; + +import { VintageController } from '../../../controllers'; + +const VintageRouter = express.Router(); + +VintageRouter.get('/', (req, res) => { + return VintageController.findAll(req, res); +}); + +export { VintageRouter };