Onchain Surveys will allow users to create public surveys to collect opinions from the blockchain communities to let the community make decisions and provide sentiment in a decentralized manner.
git clone https://github.com/ecndn/onchainsurveys.gitNavigate to the api folder from your terminal screen and run the following command.
npm i
You should have a mongodb account. The URI connection string needs username, password and cluster name with attached id. If not, create an account and get the uri string from https://www.mongodb.com/
Change the mongodb fields according to you in the .env file in the api folder.
Run the following code on the terminal screen and visit the http://localhost:8800 link.
Endpoints | Description | Acceptable values | Method |
---|---|---|---|
/api/surveys | add a new survey to db | POST | |
/api/surveys/id | update an existing survey with the id parameter | ObjectId | PUT |
/api/surveys/id | delete an existing survey with the id parameter | ObjectId | DEL |
/api/surveys/ | view all surveys from db | GET | |
/api/surveys/id | view a product by id from json file | ObjectId | GET |
/api/surveys/pending/0 | view all pending surveys | number | GET |
/api/pending/1 | view all opened surveys from db | number | GET |
/api/auth/register | add a new user to db | POST | |
/api/auth/login | check for existing userto login | POST | |
/api/users/admincheck/id | check admin | ObjectId | GET |
/api/users/usercheck/id | check user | ObjectId | GET |
/api/users/id | modify a user using id | ObjectId | PUT |
/api/surveys/getmysurvey/username | get surveys created by username | username | GET |
Navigate to the client folder from your terminal screen and run the following command.
npm i npm start
and then visit http://localhost:3000
Add the following codes to your .htaccess file.
RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule . /index.html [L]
We use Cypress for testing the portal's critical functionality. In order to run the test suite, you will need to copy the example cypress.example.json to cypress.json and enter your variables. Then after a successful build, npm run cypress-run for a headless unit test, or npm run cypress-open for a more detailed test interface.
cp cypress.example.json cypress.json npm run cypress-run