Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ohmyhome REST API

This REST API is an application solution for Ohmyhome Backend Engineer Examination.

The problem was to create a REST API is provide "Property" and "Country" endpoints for users to post properties they want to sell or rent out.

The REST API was written using Go Language and the Data Storage uses MySQL.

Some sample data (Countries and Properties), will be initialized into the database when the application runs.

Models

Property and Country Models design are as shown below:

Country Model:
- ID
- Country
Property Model:
- ID
- Address
- Country
- Description
- Available

API Endpoints

The REST API Endpoints allows the user to do simple CRUD operations for Property and Country information. The endpoint only accepts request where the "Content-type" is "application/json".

Country Endpoints:
- GET Methods
  - Get All Countries 
  - Get Single Country
- POST Method
  - Create New Country
- PUT Method
  - Update Country Information
- DELETE Method
  - Delete Country
Property Endpoints:
- GET Methods
  - Get All Properties (GET)
  - Get Available Properties (GET)
  - Get Properties In Country (GET)
  - Get Single Property (GET)
- POST Methods
  - Create New Property (POST)
- PUT Method
  - Update Property Information (PUT)
- DELETE Method
  - Delete Property (DELETE)

Libraries

Libraries used are:

Running the Application

  1. Clone the project from https://github.com/ksw95/OMH_BEx.git (Unless you already have the files)
  2. Create an .env file in the root folder, with these required values:
MYSQL_HOSTNAME=<host>
MYSQL_USER=<username>
MYSQL_PASSWORD=<password>
MYSQL_DBNAME=<database>
MYSQL_PORT=<port_no>
  1. Once project has been cloned and .env file has been created in the root folder, open a terminal and change directory into the project root folder and run the main.go file using the command go run main.go.

Potential Improvements

  • Dockerizing the application
  • CI/CD inclusion
  • Versioning and Throttling
  • Proper User Authentication with API Key

Testing

Application was manually tested using Postman. Tested the basic CRUD operations, ensuring sanitzation and validation are working and basic error handling via error messages.

Screenshot examples:

Getting all properties information image

Posting new property image

Getting single country image

Updating country information image

Deleting country entry image

Testing error handling via error responses image

Validation testing image

Sanitization testing image

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages