Skip to content

Foxbox Week Challenge #2. API that generates names based on a sample.

License

Notifications You must be signed in to change notification settings

DiegoVictor/named-api

Repository files navigation

[API] Named

GitHub Workflow Status (branch) GitHub go.mod Go version coverage MIT License PRs Welcome
Run in Insomnia}

Responsible for provide data to the web front-end. Generates names based on preseted datasets (list of example names), but you can upload a custom dataset (it must have at least 23 names). Was utilized the Markov Chain algorithm to generate the names, a custom script was created based on this article: Generating Startup names with Markov Chains.

Live Demo: https://named-api.onrender.com/

Table of Contents

Requirements

Usage

To start up the app run:

$ go run .

Or:

go run main.go

Or even:

$ ./scripts/run.sh

Routes

route HTTP Method params description
/datasets GET - Retrieve available datasets.
/names GET dataset query parameter. Generate names for the dataset provided.
/feedbacks POST Body with an array of feedbacks with name and value. Save good feedbacks
/upload POST Body with dataset form data (See insomnia file for good example). Create a custom dataset.

Requests

  • POST /feedbacks

Request body:

[
  {
    "name": "Jordan",
    "value": 1
  }
]
  • POST /upload

Request body:

"file"=<file>

Running the tests

To run the projects' tests the app:

$ ./scripts/test.sh

Or:

$ go test ./tests/... -cover -coverpkg=./controllers,./helpers -coverprofile=coverage-report.out

Coverage report

You can see the coverage report on root folder coverage-report.out. They are automatically created after the tests run (with you used the command above).