| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
The API_Names project is an API designed to find a name and its possible variations from a given name, and correct any misspellings. It uses the Metaphone (br) algorithm to search the database and the Levenshtein distance method for correction.
Before running the API, make sure you have MySQL installed on your machine.
DB_USERNAME=<your_username> DB_PASSWORD=<your_password> DB_NAME=<your_database_name> DB_HOST=<your_database_host> DB_PORT=<your_database_port> SECRET=<your_jwt_secret>
Replace the values with your own database credentials and a secret for JWT token generation. Worht to mention that the DB_NAME does not require an existing database.
go run main.goOn the first run, the prompt will return:
go run main.go
2023/04/12 18:48:48 - Created Database
2023/04/12 18:48:48 - Upload data start
2023/04/12 18:49:21 - Upload data finished 33.113701109s
2023/04/12 18:49:21 - Created first user
2023/04/12 18:49:21 - Listening and serving...The main endpoint for the API is http://localhost:8080/metaphone/:name. You need to log in to get an access token before you can access any other endpoint.
The following table shows the available endpoints, their corresponding HTTP methods, and a brief description:
| Req | Endpoint | Description | Success | Error |
|---|---|---|---|---|
| POST | /signup | Create a new user | Status:200 - JSON | Status: 400/401 - JSON |
| POST | /login | Login user on API | Status:200 - JSON | Status: 400/401 - JSON |
| POST | /name | Create a name in the database | Status:200 - JSON | Status: 400/401 - JSON |
| DELETE | /:id | Delete a name by given id | Status:200 - JSON | Status: 404/401 - JSON |
| PUT | /:id | Update a name by given id | Status:200 - JSON | Status: 500/401 - JSON |
| GET | /:id | Read name with given id | Status:200 - JSON | Status: 400/401 - JSON |
| GET | /name/:name | Read name with given name | Status:200 - JSON | Status: 404/401 - JSON |
| GET | /metaphone/:name | Read metaphones of given name | Status:200 - JSON | Status: 404/401 - JSON |
{
"Email": "user@user.com",
"Password": "123456"
}Return:
{
"Message": "User created",
"User": {
"ID": 2,
"CreatedAt": "2023-04-12T18:48:48.475-03:00",
"UpdatedAt": "2023-04-12T18:48:48.475-03:00",
"DeletedAt": null,
"Email": "user@user.com",
"Password": "$2a$10$crIN3KKScm.HafCl9qQkzeehuK5XUfnGrAxCyymyMPnNHkwDwHBVS"
}
}{
"Email": "user@user.com",
"Password": "123456"
}Return: status 200
{
"Message": "Login successful"
}{
"ID": 3,
"CreatedAt": "2023-04-12T18:48:48.475-03:00",
"UpdatedAt": "2023-04-12T18:48:48.475-03:00",
"DeletedAt": null,
"Name": "ARON",
"Classification": "M",
"Metaphone": "ARM",
"NameVariations": "|AARON|AHARON|AROM|ARON|ARYON|HARON|"
}{
"ID": 3,
"CreatedAt": "2023-04-12T18:48:48.475-03:00",
"UpdatedAt": "2023-04-12T18:48:48.475-03:00",
"DeletedAt": null,
"Name": "ARON",
"Classification": "M",
"Metaphone": "ARM",
"NameVariations": "|AARON|AHARON|AROM|ARON|ARYON|HARON|"
}{
"ID": 3,
"CreatedAt": "2023-04-12T18:48:48.475-03:00",
"UpdatedAt": "2023-04-12T18:48:48.475-03:00",
"DeletedAt": null,
"Name": "ARON",
"Classification": "M",
"Metaphone": "ARM",
"NameVariations": "ARON | AROM | AARON | ARYON | HARON | AHARON | "
}If you're interested in checking out my API caller, you can find it by clicking on this link
| Back | FazBrowse Home | New Git URL |