Student Name: Kenny Ho Si Chong
Matriculation Number: A0185727R
If missing any, download it before proceeding.
Steps to follow:
-
Clone and download code from github repo.
-
In root directory of project run in cmd line
$npm install
-
Open another terminal, run
$mongod
. Make sure terminal is able to detect mongoDB, check by doing$mongo --version
-
In the project root directory run
$nodemon index
-
Open browser go to http://localhost:8080/api/contacts. If set-up was successful, page will display
status: "success" message:" Contacts retrieved successfully data: []
-
To
GET
,POST
,UPDATE
andDELETE
use Postman to do so.
In Postman:
POST
& GET
- Enter request URL as
http://localhost:8080/api/contact
- For
GET
just press send - For
POST
, click ontoBody
tab and tick thex-www-form-urlencoded
option. Available key-value pairs arename
,email
,phone
,gender
, andcreate_date
. After filling click send button.
- For
UPDATE
& DELETE
- only able to run when atleast have a contact entry in DB
- Enter request URL as
http://localhost:8080/api/contact/{contact_id}
, where{contact_id}
is the id of any contact object created. Find the available{contact_id}
by usingGET
method.- For
DELETE
just press send - For
UPDATE
, selectPatch
/Put
on the dropdown bar, fill upBody
tab with key-value pair, then press send.
- For
Followed through this tutorial provided in assignment pdf.
- mocha
- chai
- fork repo & download locally this whole code
- Make sure DB is empty.
-
Make sure B1 steps 1-3 are done.
-
Make sure DB is empty, delete all existing contacts.
-
Run
$npm run test
on project root directory.i. Test should be all passing upon completion.
-
Go to Travis website
i. Follow through this tutorial step 1-3. Ignore step 4 and use the existing
.travis.yml
file. -
Update something, commit and push up to your local repo, travis should be running.
i. Build should be passing.
Writing test files for node.js projects:
Travis tutorial and set-up:
- Setting-up Travis
- Travis job lifecycle
- Travis customising build
- Possible node_js version in yml file
- Building a JavaScript and Node.js project with travis
-
Access it by using:
i. https://ly2xlzpho6.execute-api.ap-southeast-1.amazonaws.com/dev OR
ii. https://ly2xlzpho6.execute-api.ap-southeast-1.amazonaws.com/dev/api/contacts
-
To add any contacts or perform POST/GET/UPDATE/DELETE API you should use PostMan and:
i. Follow through B1 steps but replace all link of
http://localhost:8080/api/contact
tohttps://ly2xlzpho6.execute-api.ap-southeast-1.amazonaws.com/dev/api/contacts
Note:
- Remove all contacts after adding to allow test to pass.
Serverless set-up:
- https://www.serverless.com/framework/docs/providers/aws/guide/credentials/
- https://www.serverless.com/blog/serverless-express-rest-api
- https://www.serverless.com/framework/docs/providers/aws/guide/quick-start/
Travis encryption/set-ups:
- https://docs.travis-ci.com/user/encryption-keys#usage
- https://blog.travis-ci.com/2019-05-30-setting-up-a-ci-cd-process-on-github
MongoDB set-up:
- https://dev.to/adnanrahic/a-crash-course-on-serverless-apis-with-express-and-mongodb-193k
- https://medium.com/@sergio13prez/connecting-to-mongodb-atlas-d1381f184369
- Download code onto your local machine.
- Npm and Nodejs
- Express
- MongoDB
- BootstrapVue.
- Axios.
- Basically everything needed from B1 - B3 in readme of github repo (except PostMan).
- At project root directory, run $npm install
- Check for mongoDB successfully installed by using $mongo --version
- Run $nodemon index at root project directory.
- Open another terminal, cd to contactapp-frontend folder.
- Run npm run serve
To add:
- Add contact button should be displayed on Home page, click it.
- Type in the required field: name, email, phone number and select gender.
- Name should be a minimum of length 3 and alphabets only
- Email should be a valid email.
- Phone number must be at least length of 7, max length of 15 according to international phone number length.
- Click dropdown to select Gender.
- Press ‘Submit’, alert will pop-up notifying post success, press ‘Ok’.
- Contact should be added.
NOTE: ‘Submit’ button is disabled until the fields are in valid format.
To Update:
- Click onto the card view of the contact you wish to update.
- An update form should show up.
- Update field accordingly
- Press ‘Submit’ once done, a pop-up should appear. Press ‘Ok’
- Contact should be updated.
NOTE: Form validation rules apply when updating as well.
To delete:
- Click on the ‘X’ button.
- Pop-up modal should appear asking for confirmation. Click accordingly.
- Upon clicking ‘Yes!’, an alert should appear. Press ‘Ok’ and contact should be deleted.
A quick fix to CORS issue faced when using axios.
Documents regarding Vue and Vuex, how to use it:
- https://vuejs.org/v2/guide/instance.html
- https://vuejs.org/v2/cookbook/using-axios-to-consume-apis.html
A brief introduction to developing Vue apps with BootstrapVue.
BootstrapVue & validating form: