Skip to content

Commit

Permalink
feat: add vintage api
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Jan 19, 2022
1 parent d12fbff commit 3f19653
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 3 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
1 change: 1 addition & 0 deletions src/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
11 changes: 11 additions & 0 deletions src/controllers/vintage.controller.js
Original file line number Diff line number Diff line change
@@ -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] },
}),
);
};
1 change: 1 addition & 0 deletions src/models/vintages/vintages.modeltypes.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
defaultValue: () => uuidv4(),
primaryKey: true,
},
orgUid: Sequelize.STRING,
startDate: Sequelize.DATE,
endDate: Sequelize.DATE,
verificationApproach: Sequelize.STRING,
Expand Down
5 changes: 5 additions & 0 deletions src/models/vintages/vintages.stub.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/routes/v1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
1 change: 1 addition & 0 deletions src/routes/v1/resources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './projects';
export * from './units';
export * from './staging';
export * from './organization';
export * from './vintages';
13 changes: 13 additions & 0 deletions src/routes/v1/resources/vintages.js
Original file line number Diff line number Diff line change
@@ -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 };

0 comments on commit 3f19653

Please sign in to comment.