1.functions
2.in-memory data structure
3.tests
4.comments and documentation for key functionalities
5.deployed online to a free hosting platform such as Heroku
6.backend program
(1) Switch to backend branch
(2) run npm install
(3) run npm start
Q: Why I choose Angular?
A: 1. It is easier to implement a lightweight application with Angular comparing with Java. 2. As there is no need for data persistence, this application can be designed as a total front-end application without database. 3. Maybe I am more familiar with Java, but if I find some technologies more suitable for my task, I would love to learn it. It won't satisfy me just to complete the work.
Q: How this application is designed?
A: Basically there are two main components contained in the front-end application. One is the app component, which includes the form used for creating new topic and a topic list. Another is the topic component. Each topic maps to a topic component. The back-end programme is implemented with Express framework (the file name is server.js). Basically there are four request handler functions included.
1.newTopic()
- request:
- url: "/newtopic"
- method: post
- params: [title: string]
- response:
- format: json
- example:
{ "status" : "true" }
2.getTopics()
- request:
- url: "/topics"
- response:
- format: json
- example:
{ "length" : "10", "order" : "desc", "items" : [ { "id" : "1", "title" : "hello world", "votes" : "3" }, { "id" : "2", "title" : "I like Carousell", "votes" : "99" } ] }
3.voteById()
- request:
- url: "/votes"
- method: get
- params: [id: number, type: number // type's value is either 1 or -1, 1 for upvote, -1 for downvote
- response:
- format: json
- example:
{ "id" : "1", "status" : "true" }
I used Karma and Jasmine to test the angular application. There are two test files in /src/app/services which end with .spec.ts.
This application has been deployed to Heroku with the link https://redditlike.herokuapp.com/