🌹 Node.js tutorial to make Google Forms within 3 hours | Hana Forms Admin (a subsystem for users to manage forms) [demo video available]
This article describes how to make a online form creator like Google Forms Forms in Node.js. The online form creator implemented in this article consists of the following two subsystems.
Hana Forms Public: a subsystem for users to enter their answers Hana Forms Admin: a subsystem for users to manage forms
This article covers Hana Forms Admin. See Hana Forms Public for the other subsystem. The resources related to this artice are as follows:
The workflow is as follows:
- Preparing for the database
- Preparing for coding
- Coding
- Operation check
Execute the following SQL statements to prepare for the database.
Run the following command in your terminal to execute SQL statements. If you have not set a password, you do not need the -p option.
mysql -u root -p
Run the following commands in the terminal to prepare for coding.
mkdir hana-forms-admin
cd hana-forms-admin
npm init -y
npm install --save dotenv ejs express express-openid-connect morgan mysql2 nocache sequelize
touch .env api-answer-submit-delete.js api-form-initialize-add.js api-form-initialize-edit.js api-form-submit-add.js api-form-submit-delete.js api-form-submit-edit.js api-form-validate.js api-item-initialize-add.js api-item-initialize-edit.js api-item-submit-add.js api-item-submit-delete.js api-item-submit-edit.js api-item-validate.js api-option-initialize-add.js api-option-initialize-edit.js api-option-submit-add.js api-option-submit-delete.js api-option-submit-edit.js api-option-validate.js find-answer.js find-form.js find-item.js find-option.js fixture.js form.js main.js model.js render-answer-detail.js render-form-detail.js render-form-list.js render-item-detail.js render-option-detail.js static-js-app.js static-js-ui-delete.js static-js-ui-form.js validate-form.js validate-item.js validate-option.js validate.js view-answer-delete.ejs view-answer-detail.ejs view-form-add.ejs view-form-delete.ejs view-form-detail.ejs view-form-edit.ejs view-form-list.ejs view-home.ejs view-item-add.ejs view-item-delete.ejs view-item-detail.ejs view-item-edit.ejs view-layout-footer.ejs view-layout-header.ejs view-option-add.ejs view-option-delete.ejs view-option-detail.ejs view-option-edit.ejs view-partial-form.ejs view-partial-item.ejs view-partial-option.ejs
A list of source code is shown below.
- api-answer-submit-delete.js
- api-form-initialize-add.js
- api-form-initialize-edit.js
- api-form-submit-add.js
- api-form-submit-delete.js
- api-form-submit-edit.js
- api-form-validate.js
- api-item-initialize-add.js
- api-item-initialize-edit.js
- api-item-submit-add.js
- api-item-submit-delete.js
- api-item-submit-edit.js
- api-item-validate.js
- api-option-initialize-add.js
- api-option-initialize-edit.js
- api-option-submit-add.js
- api-option-submit-delete.js
- api-option-submit-edit.js
- api-option-validate.js
- find-answer.js
- find-form.js
- find-item.js
- find-option.js
- fixture.js
- form.js
- main.js
- model.js
- render-answer-detail.js
- render-form-detail.js
- render-form-list.js
- render-item-detail.js
- render-option-detail.js
- static-js-app.js
- static-js-ui-delete.js
- static-js-ui-form.js
- validate-form.js
- validate-item.js
- validate-option.js
- validate.js
- view-answer-delete.ejs
- view-answer-detail.ejs
- view-form-add.ejs
- view-form-delete.ejs
- view-form-detail.ejs
- view-form-edit.ejs
- view-form-list.ejs
- view-home.ejs
- view-item-add.ejs
- view-item-delete.ejs
- view-item-detail.ejs
- view-item-edit.ejs
- view-layout-footer.ejs
- view-layout-header.ejs
- view-option-add.ejs
- view-option-delete.ejs
- view-option-detail.ejs
- view-option-edit.ejs
- view-partial-form.ejs
- view-partial-item.ejs
- view-partial-option.ejs
Run the following command in your terminal to create tables in the database and insert records.
node -r dotenv/config fixture.js
Run the following command in your terminal to start the server.
node -r dotenv/config main.js
Go to http://localhost:3001/ in your browser.
When the login page is displayed, log in by clicking the "Continue with Google" button.
When the top page is displayed, click the "Forms" link.
When the form list page is displayed, Click the Add link.
When the form add page is displayed, enter the contents of the form and then click the "Add" button.
When the form details page is displayed, Click the Add item link.
When the form item add page is displayed, enter the contents of the form and then click the "Add" button.
When the form item details page is displayed, Click the Back link.
When the form details page is displayed, click the URL of the answer page.
When the answer page is displayed, fill in the form and then click the "Submit" button.
When the completion page is displayed, return to the form details page and reload the page.
When the form details page has reloaded, Click the answer link.
When the answer details page is displayed, check that the answer content is displayed.