Skip to content

Commit

Permalink
feat: validates that the tasks are compliant with the expected schema
Browse files Browse the repository at this point in the history
  • Loading branch information
tonitienda committed May 2, 2024
1 parent df62034 commit 7b979af
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
2 changes: 2 additions & 0 deletions backend-rest-js/src/tasks/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ function makeTaskRouter(datasource) {
const validateAddTask = ajv.compile(addTaskSchema);

async function addTask(req, res) {
console.log("Add Task Body:", req.body);

const valid = validateAddTask(req.body);
if (!valid) {
res.status(400).json(validateAddTask.errors);
Expand Down
4 changes: 2 additions & 2 deletions generate-justfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const makeJustStartTasks = ({ frontend, backend, db }) => `
start-${frontend}-${backend}-${db}:
COMPOSE_PROJECT_NAME="kadai-${frontend}-${backend}-${db}" docker compose \\
-f compose.${frontend}-frontend.yaml \\
-f compose.${backend}-backend.yaml \\
-f compose.frontend-${frontend}.yaml \\
-f compose.backend-${backend}.yaml \\
-f compose.db-${db}.yaml \\
-f compose.expose-ports.yaml \\
up --build
Expand Down
32 changes: 16 additions & 16 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ unit-test:

start-nextjs-go-inmemory:
COMPOSE_PROJECT_NAME="kadai-nextjs-go-inmemory" docker compose \
-f compose.nextjs-frontend.yaml \
-f compose.go-backend.yaml \
-f compose.frontend-nextjs.yaml \
-f compose.backend-go.yaml \
-f compose.db-inmemory.yaml \
-f compose.expose-ports.yaml \
up --build
Expand All @@ -15,8 +15,8 @@ start-nextjs-go-inmemory:

start-nextjs-go-mongo:
COMPOSE_PROJECT_NAME="kadai-nextjs-go-mongo" docker compose \
-f compose.nextjs-frontend.yaml \
-f compose.go-backend.yaml \
-f compose.frontend-nextjs.yaml \
-f compose.backend-go.yaml \
-f compose.db-mongo.yaml \
-f compose.expose-ports.yaml \
up --build
Expand All @@ -25,8 +25,8 @@ start-nextjs-go-mongo:

start-nextjs-js-inmemory:
COMPOSE_PROJECT_NAME="kadai-nextjs-js-inmemory" docker compose \
-f compose.nextjs-frontend.yaml \
-f compose.js-backend.yaml \
-f compose.frontend-nextjs.yaml \
-f compose.backend-js.yaml \
-f compose.db-inmemory.yaml \
-f compose.expose-ports.yaml \
up --build
Expand All @@ -35,8 +35,8 @@ start-nextjs-js-inmemory:

start-nextjs-js-mongo:
COMPOSE_PROJECT_NAME="kadai-nextjs-js-mongo" docker compose \
-f compose.nextjs-frontend.yaml \
-f compose.js-backend.yaml \
-f compose.frontend-nextjs.yaml \
-f compose.backend-js.yaml \
-f compose.db-mongo.yaml \
-f compose.expose-ports.yaml \
up --build
Expand All @@ -45,8 +45,8 @@ start-nextjs-js-mongo:

start-htmx-go-go-inmemory:
COMPOSE_PROJECT_NAME="kadai-htmx-go-go-inmemory" docker compose \
-f compose.htmx-go-frontend.yaml \
-f compose.go-backend.yaml \
-f compose.frontend-htmx-go.yaml \
-f compose.backend-go.yaml \
-f compose.db-inmemory.yaml \
-f compose.expose-ports.yaml \
up --build
Expand All @@ -55,8 +55,8 @@ start-htmx-go-go-inmemory:

start-htmx-go-go-mongo:
COMPOSE_PROJECT_NAME="kadai-htmx-go-go-mongo" docker compose \
-f compose.htmx-go-frontend.yaml \
-f compose.go-backend.yaml \
-f compose.frontend-htmx-go.yaml \
-f compose.backend-go.yaml \
-f compose.db-mongo.yaml \
-f compose.expose-ports.yaml \
up --build
Expand All @@ -65,8 +65,8 @@ start-htmx-go-go-mongo:

start-htmx-go-js-inmemory:
COMPOSE_PROJECT_NAME="kadai-htmx-go-js-inmemory" docker compose \
-f compose.htmx-go-frontend.yaml \
-f compose.js-backend.yaml \
-f compose.frontend-htmx-go.yaml \
-f compose.backend-js.yaml \
-f compose.db-inmemory.yaml \
-f compose.expose-ports.yaml \
up --build
Expand All @@ -75,8 +75,8 @@ start-htmx-go-js-inmemory:

start-htmx-go-js-mongo:
COMPOSE_PROJECT_NAME="kadai-htmx-go-js-mongo" docker compose \
-f compose.htmx-go-frontend.yaml \
-f compose.js-backend.yaml \
-f compose.frontend-htmx-go.yaml \
-f compose.backend-js.yaml \
-f compose.db-mongo.yaml \
-f compose.expose-ports.yaml \
up --build
Expand Down
1 change: 1 addition & 0 deletions webapp-htmx-go/pkg/tasks/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func AddTask(token string, title string, description string) error {
// TODO - See this
return err
}
req.Header.Set("content-type", "application/json")

req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
res, err := http.DefaultClient.Do(req)
Expand Down

0 comments on commit 7b979af

Please sign in to comment.