-
Notifications
You must be signed in to change notification settings - Fork 3
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 #116 from pshenmic/feat/linting
Enforce Javascript Standard linting rules
- Loading branch information
Showing
43 changed files
with
3,496 additions
and
8,815 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
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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
let cacheStorage = {} | ||
const cacheStorage = {} | ||
|
||
const cache = {} | ||
|
||
cache.set = (key, value, timeout) => { | ||
cacheStorage[key] = value | ||
cacheStorage[key] = value | ||
|
||
if (timeout) { | ||
setTimeout(() => cache.delete(key), timeout) | ||
} | ||
if (timeout) { | ||
setTimeout(() => cache.delete(key), timeout) | ||
} | ||
} | ||
|
||
cache.delete = (key) => { | ||
cacheStorage[key] = undefined | ||
cacheStorage[key] = undefined | ||
} | ||
|
||
cache.get = (key) => cacheStorage[key] | ||
cache.get = (key) => cacheStorage[key] | ||
|
||
module.exports = cache |
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,13 +1,13 @@ | ||
module.exports = { | ||
BLOCK_TIME: 5000, | ||
StateTransitionEnum: { | ||
DATA_CONTRACT_CREATE: 0, | ||
DOCUMENTS_BATCH: 1, | ||
IDENTITY_CREATE: 2, | ||
IDENTITY_TOP_UP: 3, | ||
DATA_CONTRACT_UPDATE: 4, | ||
IDENTITY_UPDATE: 5, | ||
IDENTITY_CREDIT_WITHDRAWAL: 6, | ||
IDENTITY_CREDIT_TRANSFER: 7 | ||
} | ||
BLOCK_TIME: 5000, | ||
StateTransitionEnum: { | ||
DATA_CONTRACT_CREATE: 0, | ||
DOCUMENTS_BATCH: 1, | ||
IDENTITY_CREATE: 2, | ||
IDENTITY_TOP_UP: 3, | ||
DATA_CONTRACT_UPDATE: 4, | ||
IDENTITY_UPDATE: 5, | ||
IDENTITY_CREDIT_WITHDRAWAL: 6, | ||
IDENTITY_CREDIT_TRANSFER: 7 | ||
} | ||
} |
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,34 +1,33 @@ | ||
const Block = require('../models/Block'); | ||
const BlocksDAO = require('../dao/BlocksDAO'); | ||
const BlocksDAO = require('../dao/BlocksDAO') | ||
|
||
class BlocksController { | ||
constructor(knex) { | ||
this.blocksDAO = new BlocksDAO(knex) | ||
} | ||
|
||
getBlockByHash = async (request, response) => { | ||
const {hash} = request.params | ||
constructor (knex) { | ||
this.blocksDAO = new BlocksDAO(knex) | ||
} | ||
|
||
const block = await this.blocksDAO.getBlockByHash(hash) | ||
getBlockByHash = async (request, response) => { | ||
const { hash } = request.params | ||
|
||
if (!block) { | ||
return response.status(404).send({message: 'not found'}) | ||
} | ||
const block = await this.blocksDAO.getBlockByHash(hash) | ||
|
||
response.send(block); | ||
if (!block) { | ||
return response.status(404).send({ message: 'not found' }) | ||
} | ||
|
||
getBlocks = async (request, response) => { | ||
const {page = 1, limit = 10, order = 'asc'} = request.query | ||
|
||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values`}) | ||
} | ||
response.send(block) | ||
} | ||
|
||
const blocks = await this.blocksDAO.getBlocks(Number(page), Number(limit), order) | ||
getBlocks = async (request, response) => { | ||
const { page = 1, limit = 10, order = 'asc' } = request.query | ||
|
||
response.send(blocks); | ||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({ message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values` }) | ||
} | ||
|
||
const blocks = await this.blocksDAO.getBlocks(Number(page), Number(limit), order) | ||
|
||
response.send(blocks) | ||
} | ||
} | ||
|
||
module.exports = BlocksController |
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,34 +1,33 @@ | ||
const DataContract = require("../models/DataContract"); | ||
const DataContractsDAO = require("../dao/DataContractsDAO"); | ||
const DataContractsDAO = require('../dao/DataContractsDAO') | ||
|
||
class DataContractsController { | ||
constructor(knex) { | ||
this.dataContractsDAO = new DataContractsDAO(knex) | ||
} | ||
|
||
getDataContractByIdentifier = async (request, response) => { | ||
const {identifier} = request.params | ||
constructor (knex) { | ||
this.dataContractsDAO = new DataContractsDAO(knex) | ||
} | ||
|
||
const dataContract = await this.dataContractsDAO.getDataContractByIdentifier(identifier) | ||
getDataContractByIdentifier = async (request, response) => { | ||
const { identifier } = request.params | ||
|
||
if (!dataContract) { | ||
response.status(404).send({message: 'not found'}) | ||
} | ||
const dataContract = await this.dataContractsDAO.getDataContractByIdentifier(identifier) | ||
|
||
response.send(dataContract); | ||
if (!dataContract) { | ||
response.status(404).send({ message: 'not found' }) | ||
} | ||
|
||
getDataContracts = async (request, response) => { | ||
const {page = 1, limit = 10, order = 'asc'} = request.query | ||
|
||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values`}) | ||
} | ||
response.send(dataContract) | ||
} | ||
|
||
const dataContracts = await this.dataContractsDAO.getDataContracts(Number(page), Number(limit), order); | ||
getDataContracts = async (request, response) => { | ||
const { page = 1, limit = 10, order = 'asc' } = request.query | ||
|
||
response.send(dataContracts) | ||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({ message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values` }) | ||
} | ||
|
||
const dataContracts = await this.dataContractsDAO.getDataContracts(Number(page), Number(limit), order) | ||
|
||
response.send(dataContracts) | ||
} | ||
} | ||
|
||
module.exports = DataContractsController |
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,35 +1,34 @@ | ||
const Document = require('../models/Document'); | ||
const DocumentsDAO = require('../dao/DocumentsDAO'); | ||
const DocumentsDAO = require('../dao/DocumentsDAO') | ||
|
||
class DocumentsController { | ||
constructor(knex) { | ||
this.documentsDAO = new DocumentsDAO(knex) | ||
} | ||
|
||
getDocumentByIdentifier = async (request, response) => { | ||
const {identifier} = request.params | ||
constructor (knex) { | ||
this.documentsDAO = new DocumentsDAO(knex) | ||
} | ||
|
||
const document = await this.documentsDAO.getDocumentByIdentifier(identifier) | ||
getDocumentByIdentifier = async (request, response) => { | ||
const { identifier } = request.params | ||
|
||
if (!document) { | ||
response.status(404).send({message: 'not found'}) | ||
} | ||
const document = await this.documentsDAO.getDocumentByIdentifier(identifier) | ||
|
||
response.send(document); | ||
if (!document) { | ||
response.status(404).send({ message: 'not found' }) | ||
} | ||
|
||
getDocumentsByDataContract = async (request, response) => { | ||
const {identifier} = request.params | ||
const {page = 1, limit = 10, order = 'asc'} = request.query | ||
|
||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values`}) | ||
} | ||
response.send(document) | ||
} | ||
|
||
const documents = await this.documentsDAO.getDocumentsByDataContract(identifier, Number(page), Number(limit), order) | ||
getDocumentsByDataContract = async (request, response) => { | ||
const { identifier } = request.params | ||
const { page = 1, limit = 10, order = 'asc' } = request.query | ||
|
||
response.send(documents); | ||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({ message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values` }) | ||
} | ||
|
||
const documents = await this.documentsDAO.getDocumentsByDataContract(identifier, Number(page), Number(limit), order) | ||
|
||
response.send(documents) | ||
} | ||
} | ||
|
||
module.exports = DocumentsController |
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,85 +1,85 @@ | ||
const IdentitiesDAO = require("../dao/IdentitiesDAO"); | ||
const IdentitiesDAO = require('../dao/IdentitiesDAO') | ||
|
||
class IdentitiesController { | ||
constructor(knex) { | ||
this.identitiesDAO = new IdentitiesDAO(knex) | ||
} | ||
|
||
getIdentityByIdentifier = async (request, response) => { | ||
const {identifier} = request.params; | ||
constructor (knex) { | ||
this.identitiesDAO = new IdentitiesDAO(knex) | ||
} | ||
|
||
const identity = await this.identitiesDAO.getIdentityByIdentifier(identifier) | ||
getIdentityByIdentifier = async (request, response) => { | ||
const { identifier } = request.params | ||
|
||
if (!identity) { | ||
return response.status(404).send({message: 'not found'}) | ||
} | ||
const identity = await this.identitiesDAO.getIdentityByIdentifier(identifier) | ||
|
||
response.send(identity) | ||
if (!identity) { | ||
return response.status(404).send({ message: 'not found' }) | ||
} | ||
|
||
getIdentities = async (request, response) => { | ||
const {page = 1, limit = 10, order = 'asc'} = request.query | ||
|
||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values`}) | ||
} | ||
response.send(identity) | ||
} | ||
|
||
const identities = await this.identitiesDAO.getIdentities(Number(page), Number(limit), order) | ||
getIdentities = async (request, response) => { | ||
const { page = 1, limit = 10, order = 'asc' } = request.query | ||
|
||
response.send(identities) | ||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({ message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values` }) | ||
} | ||
|
||
getTransactionsByIdentity = async (request, response) => { | ||
const {identifier} = request.params | ||
const {page = 1, limit = 10, order = 'asc'} = request.query | ||
const identities = await this.identitiesDAO.getIdentities(Number(page), Number(limit), order) | ||
|
||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values`}) | ||
} | ||
response.send(identities) | ||
} | ||
|
||
const transactions = await this.identitiesDAO.getTransactionsByIdentity(identifier, Number(page), Number(limit), order) | ||
getTransactionsByIdentity = async (request, response) => { | ||
const { identifier } = request.params | ||
const { page = 1, limit = 10, order = 'asc' } = request.query | ||
|
||
response.send(transactions) | ||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({ message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values` }) | ||
} | ||
|
||
getDataContractsByIdentity = async (request, response) => { | ||
const {identifier} = request.params | ||
const {page = 1, limit = 10, order = 'asc'} = request.query | ||
const transactions = await this.identitiesDAO.getTransactionsByIdentity(identifier, Number(page), Number(limit), order) | ||
|
||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values`}) | ||
} | ||
response.send(transactions) | ||
} | ||
|
||
const dataContracts = await this.identitiesDAO.getDataContractsByIdentity(identifier, Number(page), Number(limit), order) | ||
getDataContractsByIdentity = async (request, response) => { | ||
const { identifier } = request.params | ||
const { page = 1, limit = 10, order = 'asc' } = request.query | ||
|
||
response.send(dataContracts) | ||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({ message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values` }) | ||
} | ||
|
||
getDocumentsByIdentity = async (request, response) => { | ||
const {identifier} = request.params | ||
const {page = 1, limit = 10, order = 'asc'} = request.query | ||
const dataContracts = await this.identitiesDAO.getDataContractsByIdentity(identifier, Number(page), Number(limit), order) | ||
|
||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values`}) | ||
} | ||
response.send(dataContracts) | ||
} | ||
|
||
const documents = await this.identitiesDAO.getDocumentsByIdentity(identifier, Number(page), Number(limit), order) | ||
getDocumentsByIdentity = async (request, response) => { | ||
const { identifier } = request.params | ||
const { page = 1, limit = 10, order = 'asc' } = request.query | ||
|
||
response.send(documents) | ||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({ message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values` }) | ||
} | ||
|
||
getTransfersByIdentity = async (request, response) => { | ||
const {identifier} = request.params | ||
const {page = 1, limit = 10, order = 'asc'} = request.query | ||
const documents = await this.identitiesDAO.getDocumentsByIdentity(identifier, Number(page), Number(limit), order) | ||
|
||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values`}) | ||
} | ||
response.send(documents) | ||
} | ||
|
||
const transfers = await this.identitiesDAO.getTransfersByIdentity(identifier, Number(page), Number(limit), order) | ||
getTransfersByIdentity = async (request, response) => { | ||
const { identifier } = request.params | ||
const { page = 1, limit = 10, order = 'asc' } = request.query | ||
|
||
response.send(transfers) | ||
if (order !== 'asc' && order !== 'desc') { | ||
return response.status(400).send({ message: `invalid ordering value ${order}. only 'asc' or 'desc' is valid values` }) | ||
} | ||
|
||
const transfers = await this.identitiesDAO.getTransfersByIdentity(identifier, Number(page), Number(limit), order) | ||
|
||
response.send(transfers) | ||
} | ||
} | ||
|
||
module.exports = IdentitiesController |
Oops, something went wrong.