Townhall NodeJS Server and database
npm i
brew install postgresql
brew services start postgresql
(Only need to start it one time)
createuser -e -P "th_admin"
createdb -e -O th_admin --encoding utf8 th_development
Test connection to the db as follows:
psql -U th_admin th_development
To create all tables:
npm run migrate -- up
To undo a single migration:
npm run migrate -- down
To undo all migrations:
npm run migrate -- down --to 0
To generate a new migration:
npm run migrate -- generate
npm run seed
npm -s run dump:schema -- -U th_admin th_development > schema.sql
{
"id": 2,
"timeCreated": "2019-04-03T22:40:46.957Z",
"timeLastUpdated": null,
"name": "Saga 1",
"periods": [
{
"id": 2,
"timeCreated": "2019-04-03T22:40:46.961Z",
"timeLastUpdated": null,
"type": "PROPOSAL",
"proposals": [
{
"id": 2,
"timeCreated": "2019-04-03T22:40:46.964Z",
"timeLastUpdated": null,
"name": "Proposal 1",
"description": "Would Increase the Current Gas Limit Only."
},
{
"id": 3,
"timeCreated": "2019-04-03T22:40:46.967Z",
"timeLastUpdated": null,
"name": "Proposal 2",
"description": "Would Increase the Current Gas Limit AND Reduce the roll size requirement."
}
]
}
]
}
Gets all of the comments associated with an entire townhall.
[
{
"id": "2",
"timeCreated": "2019-04-14T00:28:22.924Z",
"timeLastUpdated": null,
"content": "Voluptatem tempora voluptates quia iusto qui vitae vero quia. Molestias nam delectus autem. Debitis voluptatem dolor accusamus harum sint quod atque aut. Tempora deserunt dolor ab corrupti eius. Voluptatem dicta molestiae aut.",
"isPro": false,
"proposal": {
"id": "2"
},
"user": {
"id": "2"
},
"townhall": {
"id": "2"
},
"comment": null
},
{
"id": "3",
"timeCreated": "2019-04-14T00:28:22.928Z",
"timeLastUpdated": null,
"content": "Blanditiis quisquam molestiae dolores vel velit nobis. Consequatur facilis optio cumque natus tenetur sunt est veritatis voluptatem. Vitae autem alias esse iure illo velit.",
"isPro": false,
"proposal": {
"id": "2"
},
"user": {
"id": "2"
},
"townhall": {
"id": "2"
},
"comment": null
}
]
Gets all votes of a townhall for each proposal. if isFor = true,the user has voted for that proposal and voted yes. if isFor = false, the user has voted for that proposal and voted no. if isFor = null the user has not voted for that proposal.
[
{
"proposal": { id : "2"},
"isFor": true,
"yes": 4,
"no": 2
},
{
"proposal": { id : "3"},
"isFor": null,
"yes": 2,
"no": 2
}
]
With my wallet plugged in: KT1BodUY4eHP1jFcaSzDB8aWa3CE8bRnPDjk
[ { cycle: 100,
delegate: { tz: 'tz1iJ4qgGTzyhaYEzd1RnC6duEkLBd1nzexh' },
staking_balance: '996500917727',
balance: 1097090142,
rewards: 586000000,
extra_rewards: 0,
losses: 0,
status: { status: 'cycle_pending' } },
{ cycle: 99,
delegate: { tz: 'tz1iJ4qgGTzyhaYEzd1RnC6duEkLBd1nzexh' },
staking_balance: '1023034717474',
balance: 1097090142,
rewards: 520000000,
extra_rewards: 0,
losses: 0,
status: { status: 'cycle_pending' } } ]
Content type
Image
Digest
Size
371.5 MB
Last updated
over 7 years ago
docker pull bbcowboy/townhall-server-db