Skip to content

Latest commit

 

History

History
102 lines (78 loc) · 2.12 KB

README.md

File metadata and controls

102 lines (78 loc) · 2.12 KB

scalakurs-blogg

Forberedelser

Oppdatere kildekode for kurset med git

$ cd scalakurs
$ git pull
$ cd oppgaver/del-3

Eller sjekke ut på nytt med git

$ git clone https://github.com/froden/scalakurs.git
$ cd scalakurs/oppgaver/del-3

Installere mongoDB

  1. Last ned mongoDB

  2. Pakk ut :

$ tar zxvf mongodb-linux-x86_64-2.4.8.tgz

(eller unzip i windows)

  1. Lag katalog til databasen:
$ mkdir -p /home/sjur/mongodbdata

(fks)

  1. Start mongodb slik:
$ /home/sjur/mongo_installed_here/bin/mongodb --dbpath /home/sjur/mongodbdata
$ cd ~/scalakurs/oppgaver/del-3/

Kjøre appen med autorestart ved kodeendringer

$ ./sbt
> ~re-start

Åpne http://localhost:8080/ i nettleseren

Stoppe appen

> re-stop

Oppgave

  • Implementer scalakurs.ArticlesController slik at artikler kan addes og editeres, og kommentarer legges på artikler

Følgende API i backend forventes av front-end appen:

GET    /articles               #get all articles
POST   /articles               #create new article
GET    /articles/:id           #get single article
PUT    /articles/:id           #update existing article
DELETE /articles/:id           #remoeve article
POST   /articles/:id/comments  #create new comment on article
DELETE /articles/:id/comments  #delete all comments from article

#article with comments
{
    "_id": "1234zxcvdas",
    "author": "Frode",
    "title": "A blogpost",
    "content": "Loong and informative post"
    "comments": [
        {
            "author": "Sjur",
            "content": "Nice post!",
        },
        {
            "author": "Arild",
            "content": "Could be shorter."
        }
    ]
}

Nyttige linker