{"_id":"@aragon/court-backend-server","_rev":"38-55c56ab169c6127f2c9ce25275277ed3","name":"@aragon/court-backend-server","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@aragon/court-backend-server","version":"0.0.1","author":{"name":"Aragon One"},"license":"(GPL-3.0-or-later OR AGPL-3.0-or-later)","_id":"@aragon/court-backend-server@0.0.1","maintainers":[{"name":"ajsantander","email":"palebluedot@gmail.com"},{"name":"evalir","email":"hi@enriqueortiz.dev"},{"name":"gabrielg","email":"gabrielpk.18@gmail.com"},{"name":"facuspagnuolo","email":"facundo_spagnuolo@icloud.com"},{"name":"aragon-ci","email":"jorge+npmci@aragon.one"},{"name":"bingen","email":"bingen@aragon.one"},{"name":"izqui","email":"jorge@aragon.one"},{"name":"luisivan","email":"me@luisivan.net"},{"name":"bpierre","email":"hello@pierre.world"},{"name":"sohkai","email":"qisheng.brett.sun@gmail.com"}],"dist":{"shasum":"7b2ccff4ab5ab5a77f14faf2ddfbd115499ccb99","tarball":"https://registry.npmjs.org/@aragon/court-backend-server/-/court-backend-server-0.0.1.tgz","fileCount":32,"integrity":"sha512-QSLGQFMvBlmxW8MVZ036vWiAFqwXyD0XikSI1EILhCwPrJFC50B0s2hu2PyKs+WUK5I1y9vFeX2Q4NsCLRp8uQ==","signatures":[{"sig":"MEQCIEP/UgHqrz90PPQjU4MPPp/SPISL1KMSxryhZihnYMatAiAg5ZegvhuEp9fRjVGyUdh91EZJB8GcwUiT/0Pl6zUJSw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":32628,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh111SCRA9TVsSAnZWagAA5BoP/0SAX3NfPxRKCuenbi3P\n6v0rgHsTuGKDya7Mj79y8h4FBLCHLGzruAhYqns5OuW7h/Wwu2Sa4bKCd+tR\nLR3+ljksCRJzhaBvRSeNmyi4rTym6kC/Y4Fk5bFJkXxfCK9+SaStHkaKWpiW\njUfKlIrZN5fbM6tm3fnkuCa6RlGqhy3F4jVO/1hfRloZVY7QfaVzTn9tc5d1\nnCEXxMFC5OqWVQ3BmzR2m5rRpOtqx1ksv45TYHXti+kVAmEODHHWc+CvcVhH\nht/gvNcStvq21G6XMCu/m1UyUo4CgUQEboG8qBroNr4nd41L2FQmLXKCacBj\nmEqp5nTkJvqhKMCgHU/U3XHGEAuMg3YALr9cLSUgFOZeTc0NHbtpUODlS684\nhgw041UVnCQEGPhPnXU4G1DD/cWRZyCodZ16UDAi07MFJZuGCiTrlZmoIrAP\nZwhD11SlNmLMwXmOJzJGSLTVlWUtg/g0ldszdszDK4ATRqyGLLekUpy7GoR+\nAXpVFiDdlIBA9gJx177u/RDl5s4dqiMdJNYwu0wRTsMvgGY/tShWLQhqp082\nKTfE753beEZyQpoHCRfIu6gSzHH+i0FU0mUi22rFF4BTEr5TGmiHVQjCvdzx\niMDk3v5nyiyJPEZc4KRaNbhYv6EA5ZJUJQ4Ray05dmrnFIq04U0Fll7Ht7Rj\n5woS\r\n=k6Go\r\n-----END PGP SIGNATURE-----\r\n"},"engines":{"node":">=9.0.0"},"scripts":{"dev":"nodemon --ignore ./build --exec babel-node ./src/index.js","build":"babel ./src --out-dir ./build --source-maps --copy-files","start":"node ./build"},"_npmUser":{"name":"bingen","email":"bingen@aragon.one"},"deprecated":"Hey! court-backend-server should not have been published nor be used as a dependency!","_npmVersion":"6.13.4","description":"This server aims to provide different kind of services to complement the logic implemented at the smart contracts level.","directories":{},"_nodeVersion":"10.15.0","dependencies":{"pg":"^7.15.1","cors":"^2.8.5","dotenv":"^8.2.0","helmet":"^3.21.2","morgan":"^1.9.1","core-js":"^3.6.2","express":"^4.17.1","bcryptjs":"^2.4.3","pg-hstore":"^2.3.3","sequelize":"^5.21.3","web3-utils":"^1.2.4","body-parser":"^1.19.0","prom-client":"^11.5.3","jsonwebtoken":"^8.5.1","@aragon/court":"1.1.0","@promster/server":"^4.0.0","@promster/express":"^4.0.0","regenerator-runtime":"^0.13.3","@aragon/court-backend-shared":"^0.0.1"},"_hasShrinkwrap":false,"devDependencies":{"nodemon":"^2.0.2","@babel/cli":"^7.7.7","@babel/core":"^7.7.7","@babel/node":"^7.7.7","sequelize-cli":"^5.5.1","@babel/preset-env":"^7.7.7"},"_npmOperationalInternal":{"tmp":"tmp/court-backend-server_0.0.1_1581070591898_0.5895566099901206","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-02-07T10:16:31.792Z","modified":"2025-05-09T12:19:04.469Z","0.0.1":"2020-02-07T10:16:31.986Z"},"author":{"name":"Aragon One"},"license":"(GPL-3.0-or-later OR AGPL-3.0-or-later)","description":"This server aims to provide different kind of services to complement the logic implemented at the smart contracts level.","maintainers":[{"email":"devops-master@aragon.org","name":"devops-master"},{"email":"jjavieralvarezrodriguez@gmail.com","name":"jjavieralv"},{"email":"devops@aragon.org","name":"arabot-1"}],"readme":"# Court Backend server\n\nThis server aims to provide different kind of services to complement the logic implemented at the smart contracts level.\n\n## Setup\n\nFirst clone this repo and install dependencies:\n\n````bash\ngit clone https://github.com/aragonone/court-backend/\ncd court-backend\nnpm i\nnpx lerna bootstrap\ncd packages/server\n````\n\nTo run the server simply create your own `.env` file, feel free to follow the template provided in `.env.sample`.\nOnce you have done that, spin up a docker container with:\n```bash\ndocker-compose up -d\n```\n\nIf you had run it before, make sure to remove it first:\n```bash\ndocker-compose down\n```\n\n\nand simply run the following commands:\n\n```bash\nnpx sequelize db:create\nnpx sequelize db:migrate\nnpx sequelize db:seed:all\nnpm start\n```\n\nRemember to append `NODE_ENV=production` if needed.\n\n## Endpoints\n\nAll the provided endpoints are `Content-Type: application/json`\n\n### 1. Subscriptions\n\n#### 1.1. Create\n\n- URL: /subscriptions\n- Method: POST\n- Body: \n  - `email`: Email address, string mandatory\n  - `address`: Ethereum address, string not mandatory\n- Response: \n  - Code: 200\n  - Content example: \n    ```json\n      {\n        \"id\": 4,\n        \"email\": \"bla@gmail.com\",\n        \"address\": \"0xd5931f0a36FE76845a5330f6D0cd7a378401e34d\",\n        \"updatedAt\":\"2019-12-19T16:00:18.208Z\",\n        \"createdAt\":\"2019-12-19T16:00:18.208Z\"\n      }\n    ```\n\n#### 1.2. All\n\n- URL: /subscriptions\n- Method: GET\n- Query: \n  - `token`: JSON web token\n  - `limit`: Number of items to be fetched\n  - `page`: Page number to be used for the items to be fetched based on the limit requested\n- Response: \n  - Code: 200\n  - Content example: \n    ```json\n      {\n        \"subscriptions\":[\n          {\n            \"id\": 9,\n            \"email\": \"juan@aragon.one\",\n            \"address\": \"0xd5931f0a36FE76845a5330f6D0cd7a378401\",\n            \"createdAt\": \"2019-12-25T14:58:58.705Z\",\n            \"updatedAt\":\"2019-12-25T14:58:58.705Z\"\n          },\n          {\n            \"id\": 8,\n            \"email\": \"delfi@aragon.one\",\n            \"address\": \"0xd5931f0a36FE76845a5330f6D0cd7a378401\",\n            \"createdAt\": \"2019-12-25T14:58:52.433Z\",\n            \"updatedAt\": \"2019-12-25T14:58:52.433Z\"\n          }\n        ],\n        \"total\": 9\n      }\n    ```\n\n### 2. Reveals\n\n#### 2.1. Create\n\n- URL: /reveals\n- Method: POST\n- Body: \n  - `juror`: Ethereum address of the juror requesting for the reveal \n  - `voteId`: Vote ID to be revealed for the given juror\n  - `outcome`: Outcome voted in favor of\n  - `salt`: Salt used for the committed vote to be revealed\n- Response: \n  - Code: 200\n  - Content example: \n    ```json\n      {\n        \"reveal\": {\n          \"id\": 1,\n          \"juror\": \"0xd5931f0a36FE76845a5330f6D0cd7a378401\",\n          \"voteId\": \"0\", \n          \"disputeId\": \"0\", \n          \"roundNumber\": \"0\",\n          \"createdAt\": \"2019-12-25T14:58:58.705Z\",\n          \"updatedAt\":\"2019-12-25T14:58:58.705Z\"\n        }\n      }\n    ```\n\n#### 2.2. Show\n\n- URL: /reveal\n- Method: GET\n- Body: \n  - `juror`: Ethereum address of the juror requesting for the reveal \n  - `voteId`: Vote ID to be revealed for the given juror\n- Response: \n  - Code: 200\n  - Content example: \n    ```json\n      {\n        \"reveal\": {\n          \"id\": 1,\n          \"juror\": \"0xd5931f0a36FE76845a5330f6D0cd7a378401\",\n          \"voteId\": \"0\", \n          \"disputeId\": \"0\", \n          \"roundNumber\": \"0\",\n          \"createdAt\": \"2019-12-25T14:58:58.705Z\",\n          \"updatedAt\":\"2019-12-25T14:58:58.705Z\"\n        }\n      }\n    ```\n\n#### 2.3. All\n\n- URL: /reveals\n- Method: GET\n- Query: \n  - `token`: JSON web token\n  - `limit`: Number of items to be fetched\n  - `page`: Page number to be used for the items to be fetched based on the limit requested\n- Response: \n  - Code: 200\n  - Content example: \n    ```json\n      {\n        \"reveals\":[\n          {\n            \"id\": 9,\n            \"juror\": \"0xd5931f0a36FE76845a5330f6D0cd7a378401\",\n            \"voteId\": \"0\", \n            \"disputeId\": \"0\", \n            \"roundNumber\": \"0\",\n            \"outcome\": \"4\",\n            \"salt\": \"0x609a2445eb34bc29b4d87aea2cae24fba90a1583b14df2d765ae1f89d32b4beb\",\n            \"revealed\": false,\n            \"tries\": 3,\n            \"errorId\": 41,\n            \"createdAt\": \"2019-12-25T14:58:58.705Z\",\n            \"updatedAt\":\"2019-12-25T14:58:58.705Z\"\n          }\n        ],\n        \"total\": 1\n      }\n    ```\n\n### 3. Admins\n\n#### 3.1. Login\n\n- URL: /login\n- Method: POST\n- Body: \n  - `email`: Admin email\n  - `password`: Admin password\n- Response: \n  - Code: 200\n  - Content example: \n    ```json\n      {\n        \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZG1pbiI6ImZhY3VAYXJhZ29uLm9uZSIsImlhdCI6MTU3ODA4MTI5NCwiZXhwIjoxNTc4MDg0ODk0fQ.lmcJOE0eblD_maqXqyK0_H2swXnvG9lfEm1aJRGiAVw\"\n      }\n    ```\n    \n\n#### 3.2. Me\n\n- URL: /me\n- Method: GET\n- Query: \n  - `token`: JSON web token\n- Response: \n  - Code: 200\n  - Content example: \n    ```json\n      {\n        \"admin\": {\n          \"id\": 1,\n          \"email\": \"admin@aragon.one\"\n        }\n      }\n    ```\n\n#### 3.3. All\n\n- URL: /admins\n- Method: GET\n- Query: \n  - `token`: JSON web token\n  - `limit`: Number of items to be fetched\n  - `page`: Page number to be used for the items to be fetched based on the limit requested\n- Response: \n  - Code: 200\n  - Content example: \n    ```json\n      {\n        \"reveals\":[\n          {\n            \"id\": 9,\n            \"juror\": \"0xd5931f0a36FE76845a5330f6D0cd7a378401\",\n            \"voteId\": \"0\", \n            \"disputeId\": \"0\", \n            \"roundNumber\": \"0\",\n            \"outcome\": \"4\",\n            \"salt\": \"0x609a2445eb34bc29b4d87aea2cae24fba90a1583b14df2d765ae1f89d32b4beb\",\n            \"revealed\": false,\n            \"tries\": 3,\n            \"createdAt\": \"2019-12-25T14:58:58.705Z\",\n            \"updatedAt\":\"2019-12-25T14:58:58.705Z\",\n            \"error\": {\n              \"id\": 41,\n              \"context\": \"Worker 'reveal' job #1 revealing vote ID 0 for juror 0xd5931f0a36fe76845a5330f6d0cd7a378401e34d\",\n              \"message\": \"Transaction: 0x8752864b6fd59ec6365855fe17bbfc2382632e27e9d9e92e8d817e626582a757 exited with an error (status 0). Reason given: DM_INVALID_ADJUDICATION_STATE.\\n     Please check that the transaction:\\n     - satisfies all conditions set by Solidity `require` statements.\\n     - does not trigger a Solidity `revert` statement.\\n\",\n              \"stack\": \"Error: Transaction: 0x8752864b6fd59ec6365855fe17bbfc2382632e27e9d9e92e8d817e626582a757 exited with an error (status 0). Reason given: DM_INVALID_ADJUDICATION_STATE.    at PromiEvent (~/court-backend/packages/shared/node_modules/@truffle/contract/lib/promievent.js:9:30)\\n    at TruffleContract.reveal (~/court-backend/packages/shared/node_modules/@truffle/contract/lib/execute.js:169:26)\\n    at module.exports.revealFor (~/court-backend/packages/shared/models/Court.js:261:19)\\n    at process._tickCallback (internal/process/next_tick.js:68:7)\",\n              \"createdAt\": \"2019-12-25T16:06:42.304Z\",\n              \"updatedAt\": \"2019-12-25T16:06:42.304Z\"\n            }\n          }\n        ],\n        \"total\": 1\n      }\n    ```\n\n#### 3.4. Create\n\n- URL: /admins\n- Method: POST\n- Body: \n  - `token`: JSON web token\n  - `email`: Admin email \n  - `password`: Admin password\n- Response: \n  - Code: 200\n  - Content example: \n    ```json\n      {\n        \"admin\": {\n          \"id\": 2,\n          \"email\": \"admin@aragon.one\"\n        }\n      }\n    ```\n\n#### 3.5. Delete\n\n- URL: /admins/:id\n- Method: DELETE\n- Query: \n  - `token`: JSON web token \n- Response: \n  - Code: 200\n  - Content example: empty\n\n### 4. Errors\n\n#### 4.1. Show\n\n- URL: /error/:id\n- Method: GET\n- Query: \n  - `token`: JSON web token\n- Response: \n  - Code: 200\n  - Content example: \n    ```json\n      {\n        \"error\": {\n          \"id\": 45,\n          \"context\": \"Worker 'settlements' job #2 settling dispute #0\",\n          \"message\": \"fetch is not defined\", \n          \"stack\": \"ReferenceError: fetch is not defined\\n    at TruffleEnvironment.query (~/court-backend/packages/shared/models/evironments/Environment.js:19:22)\\n    at module.exports.getJurors (~/court-backend/packages/shared/models/Court.js:95:43)\\n    at module.exports.settle (~/court-backend/packages/shared/models/Court.js:346:33)\\n    at process._tickCallback (internal/process/next_tick.js:68:7)\",\n          \"createdAt\": \"2019-12-27T13:09:04.204Z\",\n          \"updatedAt\": \"2019-12-27T13:09:04.204Z\"\n        }\n      }\n    ```\n\n#### 4.2. All\n\n- URL: /errors\n- Method: GET\n- Query: \n  - `token`: JSON web token\n  - `limit`: Number of items to be fetched\n  - `page`: Page number to be used for the items to be fetched based on the limit requested\n- Response: \n  - Code: 200\n  - Content example: \n    ```json\n      {\n        \"errors\": [\n          {\n            \"id\": 45,\n            \"context\": \"Worker 'settlements' job #2 settling dispute #0\",\n            \"message\": \"fetch is not defined\", \n            \"stack\": \"ReferenceError: fetch is not defined\\n    at TruffleEnvironment.query (~/court-backend/packages/shared/models/evironments/Environment.js:19:22)\\n    at module.exports.getJurors (~/court-backend/packages/shared/models/Court.js:95:43)\\n    at module.exports.settle (~/court-backend/packages/shared/models/Court.js:346:33)\\n    at process._tickCallback (internal/process/next_tick.js:68:7)\",\n            \"createdAt\": \"2019-12-27T13:09:04.204Z\",\n            \"updatedAt\": \"2019-12-27T13:09:04.204Z\"\n          },\n          {\n            \"id\": 44,\n            \"context\": \"Worker 'settlements' job #1 settling dispute #0\",\n            \"message\": \"Cannot read property 'rounds' of undefined\",\n            \"stack\": \"TypeError: Cannot read property 'rounds' of undefined\\n    at module.exports.getJurors (~/court-backend/packages/shared/models/Court.js:100:27)\\n    at module.exports.settle (~/court-backend/packages/shared/models/Court.js:346:33)\\n    at process._tickCallback (internal/process/next_tick.js:68:7)\",\n            \"createdAt\": \"2019-12-27T13:00:34.091Z\",\n            \"updatedAt\": \"2019-12-27T13:00:34.091Z\"\n          }\n        ],\n        \"total\": 45\n      }\n    ```\n","readmeFilename":"README.md"}