onchainsurvey

1.0.12 • Public • Published

What is Onchain Surveys

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.

API SETUP

Step 1: Clone this project to www or htdocs folder

git clone https://github.com/ecndn/onchainsurveys.git

Step 2: Install packages for API

Navigate to the api folder from your terminal screen and run the following command.

npm i

Step 3: Mongodb

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.

Step 4: Run the project

Run the following code on the terminal screen and visit the http://localhost:8800 link.

Step 5: Endpoints

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

CLIENT SETUP

Step 1: Install packages for CLIENT

Navigate to the client folder from your terminal screen and run the following command.

npm i
npm start

and then visit http://localhost:3000

Step 2:

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]

Testing

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

Package Sidebar

Install

npm i onchainsurvey

Weekly Downloads

2

Version

1.0.12

License

ISC

Unpacked Size

1.26 MB

Total Files

82

Last publish

Collaborators

  • ecndn