-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7fb0fa
commit 09c26c0
Showing
24 changed files
with
360 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
const modelTypes = require('../src/models/audit/audit.modeltypes.cjs'); | ||
|
||
module.exports = { | ||
async up(queryInterface) { | ||
await queryInterface.createTable('audit', modelTypes); | ||
}, | ||
|
||
async down(queryInterface) { | ||
await queryInterface.dropTable('audit'); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Audit } from '../models'; | ||
|
||
export const findAll = async (req, res) => { | ||
try { | ||
const { orgUid } = req.query; | ||
const auditResults = await Audit.findAll({ where: { orgUid } }); | ||
return res.json(auditResults); | ||
} catch (error) { | ||
res.status(400).json({ | ||
message: 'Can not retreive issuances', | ||
error: error.message, | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import stub from './audit.stub.json'; | ||
|
||
export const SimulatorMock = { | ||
findAll: () => stub, | ||
findOne: (id) => { | ||
return stub.find((record) => record.id == id); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
import Sequelize from 'sequelize'; | ||
const { Model } = Sequelize; | ||
import { sequelize, safeMirrorDbHandler } from '../database'; | ||
import { AuditMirror } from './audit.model.mirror'; | ||
import ModelTypes from './audit.modeltypes.cjs'; | ||
|
||
class Audit extends Model { | ||
static async create(values, options) { | ||
safeMirrorDbHandler(() => AuditMirror.create(values, options)); | ||
return super.create(values, options); | ||
} | ||
|
||
static async destroy(values, options) { | ||
safeMirrorDbHandler(() => AuditMirror.destroy(values, options)); | ||
return super.destroy(values, options); | ||
} | ||
|
||
static async upsert(values, options) { | ||
safeMirrorDbHandler(() => AuditMirror.upsert(values, options)); | ||
return super.upsert(values, options); | ||
} | ||
} | ||
|
||
Audit.init(ModelTypes, { | ||
sequelize, | ||
modelName: 'audit', | ||
freezeTableName: true, | ||
timestamps: true, | ||
createdAt: true, | ||
updatedAt: true, | ||
}); | ||
|
||
export { Audit }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
import Sequelize from 'sequelize'; | ||
const { Model } = Sequelize; | ||
|
||
import { sequelizeMirror, safeMirrorDbHandler } from '../database'; | ||
import ModelTypes from './audit.modeltypes.cjs'; | ||
|
||
class AuditMirror extends Model {} | ||
|
||
safeMirrorDbHandler(() => { | ||
AuditMirror.init(ModelTypes, { | ||
sequelize: sequelizeMirror, | ||
modelName: 'audit', | ||
freezeTableName: true, | ||
timestamps: true, | ||
createdAt: true, | ||
updatedAt: true, | ||
}); | ||
}); | ||
|
||
export { AuditMirror }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const Sequelize = require('sequelize'); | ||
|
||
module.exports = { | ||
id: { | ||
type: Sequelize.INTEGER, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
orgUid: { | ||
type: Sequelize.STRING, | ||
required: true, | ||
allowNull: false, | ||
}, | ||
registryId: { | ||
type: Sequelize.STRING, | ||
required: true, | ||
allowNull: false, | ||
}, | ||
rootHash: { | ||
type: Sequelize.STRING, | ||
required: true, | ||
allowNull: false, | ||
}, | ||
type: { | ||
type: Sequelize.STRING, | ||
required: true, | ||
allowNull: false, | ||
}, | ||
change: { | ||
type: Sequelize.STRING, | ||
required: true, | ||
allowNull: true, | ||
}, | ||
table: { | ||
type: Sequelize.STRING, | ||
required: true, | ||
allowNull: true, | ||
}, | ||
onchainConfirmationTimeStamp: { | ||
type: 'TIMESTAMP', | ||
required: true, | ||
allowNull: false, | ||
}, | ||
createdAt: { | ||
type: Sequelize.DATE, | ||
defaultValue: Sequelize.NOW, | ||
}, | ||
updatedAt: { | ||
type: Sequelize.DATE, | ||
defaultValue: Sequelize.NOW, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './audit.model.js'; | ||
export * from './audit.mock.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
import express from 'express'; | ||
import joiExpress from 'express-joi-validation'; | ||
|
||
import { AuditController } from '../../../controllers'; | ||
import { auditGetSchema } from '../../../validations'; | ||
|
||
const validator = joiExpress.createValidator({ passError: true }); | ||
const AuditRouter = express.Router(); | ||
|
||
AuditRouter.get('/', validator.query(auditGetSchema), (req, res) => { | ||
return AuditController.findAll(req, res); | ||
}); | ||
|
||
export { AuditRouter }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.