-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #382 from joonaun93/master
#294 Implement missing end point (Wallet event list)
- Loading branch information
Showing
28 changed files
with
1,446 additions
and
240 deletions.
There are no files selected for viewing
22 changes: 11 additions & 11 deletions
22
database/migrations/20200901213252-CreateEnumWalletEventType.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
|
||
|
||
let dbm; | ||
let type; | ||
let seed; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function(options, seedLink) { | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function (options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
}; | ||
|
||
exports.up = function(db) { | ||
return db.runSql("CREATE TYPE wallet_event_type AS ENUM ('trust_request', 'trust_request_granted', 'trust_request_cancelled_by_originator', 'trust_request_cancelled_by_actor', 'trust_request_cancelled_by_target', 'transfer_requested', 'transfer_request_cancelled_by_source', 'transfer_request_cancelled_by_destination', 'transfer_request_cancelled_by_originator', 'transfer_pending_cancelled_by_source', 'transfer_pending_cancelled_by_destination', 'transfer_pending_cancelled_by_requestor', 'transfer_completed', 'transfer_failed')"); | ||
exports.up = function (db) { | ||
return db.runSql( | ||
"CREATE TYPE wallet_event_type AS ENUM ('trust_request', 'trust_request_granted', 'trust_request_cancelled_by_originator', 'trust_request_cancelled_by_actor', 'trust_request_cancelled_by_target', 'transfer_requested', 'transfer_request_cancelled_by_source', 'transfer_request_cancelled_by_destination', 'transfer_request_cancelled_by_originator', 'transfer_pending_cancelled_by_source', 'transfer_pending_cancelled_by_destination', 'transfer_pending_cancelled_by_requestor', 'transfer_completed', 'transfer_failed')", | ||
); | ||
}; | ||
|
||
exports.down = function(db) { | ||
return db.runSql("DROP TYPE wallet_event_type"); | ||
exports.down = function (db) { | ||
return db.runSql('DROP TYPE wallet_event_type'); | ||
}; | ||
|
||
exports._meta = { | ||
"version": 1 | ||
version: 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
36 changes: 36 additions & 0 deletions
36
database/migrations/20230916050749-AlterWalletEventTypeEnum.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function (options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
}; | ||
|
||
exports.up = function (db) { | ||
return db.runSql( | ||
`ALTER TYPE wallet_event_type ADD VALUE 'login'; | ||
ALTER TYPE wallet_event_type ADD VALUE 'wallet_created';`, | ||
); | ||
}; | ||
|
||
exports.down = function (db) { | ||
return db.runSql(` | ||
CREATE TYPE wallet_event_type_original AS ENUM ('trust_request', 'trust_request_granted', 'trust_request_cancelled_by_originator', 'trust_request_cancelled_by_actor', 'trust_request_cancelled_by_target', 'transfer_requested', 'transfer_request_cancelled_by_source', 'transfer_request_cancelled_by_destination', 'transfer_request_cancelled_by_originator', 'transfer_pending_cancelled_by_source', 'transfer_pending_cancelled_by_destination', 'transfer_pending_cancelled_by_requestor', 'transfer_completed', 'transfer_failed'); | ||
ALTER TABLE wallet_event | ||
ALTER COLUMN type TYPE wallet_event_type_original USING wallet_event_type::text::wallet_event_type_original; | ||
DROP TYPE wallet_event_type; | ||
ALTER TYPE wallet_event_type_original RENAME TO wallet_event_type; | ||
`); | ||
}; | ||
|
||
exports._meta = { | ||
version: 1, | ||
}; |
30 changes: 30 additions & 0 deletions
30
database/migrations/20230916052558-AddPayloadToWalletEventTable.js.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function (options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
}; | ||
|
||
exports.up = function (db) { | ||
return db.addColumn('wallet_event', 'payload', { | ||
type: 'json', | ||
notNull: true, | ||
}); | ||
}; | ||
|
||
exports.down = function (db) { | ||
return db.removeColumn('wallet_event', 'payload'); | ||
}; | ||
|
||
exports._meta = { | ||
version: 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,22 @@ | ||
const EventService = require('../../services/EventService'); | ||
|
||
const { eventsGetQuerySchema } = require('./schemas'); | ||
|
||
const eventsGet = async (req, res) => { | ||
await eventsGetQuerySchema.validateAsync(req.query, { abortEarly: false }); | ||
|
||
const { limit, since, wallet } = req.query; | ||
|
||
const eventService = new EventService(); | ||
|
||
const events = await eventService.getAllEvents({ | ||
limit, | ||
since, | ||
wallet, | ||
walletLoginId: req.wallet_id, | ||
}); | ||
|
||
res.status(200).json({ events }); | ||
}; | ||
|
||
module.exports = { eventsGet }; |
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,9 @@ | ||
const Joi = require('joi'); | ||
|
||
const eventsGetQuerySchema = Joi.object({ | ||
limit: Joi.number().required(), | ||
since: Joi.date().iso(), | ||
wallet: Joi.string(), | ||
}); | ||
|
||
module.exports = { eventsGetQuerySchema }; |
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.