Skip to content

This repository corresponds to the backend made in Go for the Oncar frontend application.

Notifications You must be signed in to change notification settings

ellenmariadev/oncar-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oncar Backend

This repository corresponds to the backend made in Go for the frontend application.
To learn more about the requirements for this project, go to: https://github.com/oncarapp/job_challenge

If you like, use insomnia - data/insomnia.json.

○ [ Vehicles ] Routes

Method Route Description
GET api/vehicles Returns all vehicles.
GET api/vehicle/id Returns a specific vehicle
POST api/vehicle Create a new vehicle.
PATCH api/vehicle/id Update vehicle.
DELETE api/vehicle/id Delete vehicle.

Body JSON Data Request (POST Vehicle)

{
    "brand": "Audi",
    "model": "A4",
    "price": 40000,
    "year": 2016
}

○ [ Leads ] Routes

Method Route Description
GET api/leads Returns all leads.
POST api/lead Create a new lead.

○ Create and connect your database

Go to the file ./config/database.go and change the credentials.

host     = "localhost"
port     = 5432
user     = "<your db user>"
password = "<your db password>"
dbName   = "<your db name>"

○ Create the tables in your database (using PostgresSQL)

  CREATE TABLE public.vehicle(
    id serial4 NOT NULL,
    "brand" varchar NULL,
    "model" varchar NULL,
    "price" decimal NULL,
    "year" integer NULL,
    CONSTRAINT vehicle_pk PRIMARY KEY (id)
);

CREATE TABLE public.lead(
    id serial4 NOT NULL,
    "name" varchar NULL,
    "email" varchar NULL,
    "phone" varchar NULL,
    "vehicleid" int4 NULL,
    CONSTRAINT lead_pk PRIMARY KEY (id),
    CONSTRAINT vehicle_fk FOREIGN KEY (vehicleid) REFERENCES public.vehicle(id)
);

⚙️ Running this project locally

Warning Requirements: Go.

# Clone repository
$ git clone <https://github.com/ellenmariadev/oncar-backend.git>

# Navigate to the root directory of the project
$ cd oncar-backend

# Run application 
$ go run main.go

# Server running at PORT 5000
$ <http://localhost:5000>

About

This repository corresponds to the backend made in Go for the Oncar frontend application.

Topics

Resources

Stars

Watchers

Forks

Languages