silasstoffel / base39-challenge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Base39-challenge

Package Technology Technology Technology Technology

Backend technical challenge from Base39.

Requirements

Setup

# linux/iOS (create default .env and run docker-compose)
$ sh ./scripts/dev.sh

Manual setup:

  • Create .env file (use .env.example as example)
  • npm run start

Tests

# test without coverage report
npm run test

# test with coverage report
npm run test:coverage

Techs

This challenge was solved using some principles and techniques such as:

  • Clean Architecture
  • SOLID
  • RESTful
  • Object Calisthenics
  • Repositories
  • Test
  • Github Workflows (Build, Test, SonarCloud for code analysis and test coverage)

API Docs

Create Menu

POST: /api/v1/menu

Body:

{
	"name": "Menu",
	"relatedId": "parent menu (optional value)"
}

Responses:

200 - Created

{ "id": "Menu" }

400 - Validation errors

409 - Menu Already exists

422 - Invalid related menu

{ "code": "XXX", "message": "YYY" }

Load Menu

GET: /api/v1/menu

Response:

200 - Completed menu

[
    {
        "id": "10",
        "name": "Category",
        "submenus": [
            {
                "id": "11",
                "name": "Subcategory",
                "submenus": []
            }
        ]
    }
]

Delete Menu

GET: /api/v1/menu/:menu_id

Response:

200 - Delete menu

404 - Menu not found

About


Languages

Language:TypeScript 99.5%Language:Shell 0.5%