Skip to content

Commit

Permalink
Merge pull request #59 from Onyxmoon/feature/add-sveltekit-as-fronten…
Browse files Browse the repository at this point in the history
…d-framework

Feature/add sveltekit as frontend framework
  • Loading branch information
doriengr authored Nov 3, 2023
2 parents 44047a2 + 3a0fc96 commit 630451f
Show file tree
Hide file tree
Showing 47 changed files with 2,838 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/product-service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func main() {

handler := router.New(productsController, pricesController)

if err := http.ListenAndServe(":3001", handler); err != nil {
if err := http.ListenAndServe(":3003", handler); err != nil {
log.Fatalf("error while listen and serve: %s", err.Error())
}
}
Expand Down
34 changes: 33 additions & 1 deletion src/shoppinglist-service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"hsfl.de/group6/hsfl-master-ai-cloud-engineering/shoppinglist-service/api/router"
"hsfl.de/group6/hsfl-master-ai-cloud-engineering/shoppinglist-service/userShoppingList"
"hsfl.de/group6/hsfl-master-ai-cloud-engineering/shoppinglist-service/userShoppingList/model"
"hsfl.de/group6/hsfl-master-ai-cloud-engineering/shoppinglist-service/userShoppingListEntry"
"log"
"net/http"
Expand All @@ -11,13 +12,44 @@ import (
func main() {
shoppingListRepository := userShoppingList.NewDemoRepository()
shoppingListController := userShoppingList.NewDefaultController(shoppingListRepository)
createContent(shoppingListRepository)

shoppingListEntryRepository := userShoppingListEntry.NewDemoRepository()
shoppingListEntryController := userShoppingListEntry.NewDefaultController(shoppingListEntryRepository)

handler := router.New(shoppingListController, shoppingListEntryController)

if err := http.ListenAndServe(":3001", handler); err != nil {
if err := http.ListenAndServe(":3002", handler); err != nil {
log.Fatalf("error while listen and serve: %s", err.Error())
}
}

func createContent(shoppingListRepository userShoppingList.Repository) {
shoppingLists := []*model.UserShoppingList{
{
Id: 1,
UserId: 2,
Description: "Frühstück mit Anne",
Completed: false,
},
{
Id: 2,
UserId: 2,
Description: "Geburtstagskuchen",
Completed: false,
},
{
Id: 3,
UserId: 4,
Description: "Einkauf für die Woche",
Completed: true,
},
}

for _, price := range shoppingLists {
_, err := shoppingListRepository.Create(price)
if err != nil {
return
}
}
}
5 changes: 3 additions & 2 deletions src/shoppinglist-service/userShoppingList/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package userShoppingList
import "net/http"

type JsonFormatUpdateListRequest struct {
UserId uint64 `json:"userId,omitempty"`
Checked bool `json:"checked,omitempty"`
UserId uint64 `json:"userId,omitempty"`
Description string `json:"description,omitempty"`
Checked bool `json:"checked,omitempty"`
}

type Controller interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ func (controller defaultController) PutList(writer http.ResponseWriter, request
}

if _, err := controller.userShoppingListRepository.Update(&model.UserShoppingList{
Id: listId,
UserId: userId,
Completed: requestData.Checked,
Id: listId,
UserId: userId,
Description: requestData.Description,
Completed: requestData.Checked,
}); err != nil {
writer.WriteHeader(http.StatusInternalServerError)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,16 @@ func setupMockListRepositoryError() Repository {
func setupDemoListSlice() []*model.UserShoppingList {
return []*model.UserShoppingList{
{
Id: 1,
UserId: 2,
Completed: false,
Id: 1,
UserId: 2,
Description: "Frühstück mit Anne",
Completed: false,
},
{
Id: 3,
UserId: 4,
Completed: true,
Id: 3,
UserId: 4,
Description: "Geburtstagskuchen",
Completed: true,
},
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package model

type UserShoppingList struct {
Id uint64 `json:"Id,omitempty"`
UserId uint64 `json:"userId,omitempty"`
Completed bool `json:"completed,omitempty"`
Id uint64 `json:"Id,omitempty"`
UserId uint64 `json:"userId,omitempty"`
Description string `json:"description,omitempty"`
Completed bool `json:"completed,omitempty"`
}
2 changes: 1 addition & 1 deletion src/user-service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func main() {
handler := router.New()

if err := http.ListenAndServe(":8080", handler); err != nil {
if err := http.ListenAndServe(":3001", handler); err != nil {
log.Fatalf("error while listen and serve: %s", err.Error())
}
}
9 changes: 8 additions & 1 deletion src/web-service/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# The web service component
[![Run tests (web service)](https://github.com/Onyxmoon/hsfl-master-ai-cloud-engineering/actions/workflows/run-tests-web-service.yml/badge.svg)](https://github.com/Onyxmoon/hsfl-master-ai-cloud-engineering/actions/workflows/run-tests-web-service.yml)
The web service component provides the frontend display of the application.

The web service component provides the frontend display of the application.

## Setup Frontend for development
1. Navigate in the `/frontend` folder of the web-service
2. Install dependencies: `npm ci`
3. For developing with hot module replacement use `npm run dev` and open up server provided by vite
4. For using webserver from golang use `npm run build`, run the `main.go` file and open localhost with port `:3000`.
12 changes: 12 additions & 0 deletions src/web-service/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
/static
.npmrc
Loading

0 comments on commit 630451f

Please sign in to comment.