Coder Social home page Coder Social logo

iamgrodrigues / dsdelivery-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 79 KB

rest api to manage orders that are stored into a postgresql database, developed using java 11 and spring

License: MIT License

Java 100.00%
java spring rest-api studies-java

dsdelivery-api's Introduction

DsDelivery API

Author Languages Stars Forks Contributors

A Rest API that helps you to manage orders on a delivery system ๐Ÿš€

dsdelivery-API

๐Ÿ“Œ Table of Contents

๐Ÿš€ Features

  • GET List of products sorted by name in ascending order.
  • GET List of orders that have the status as "PENDING" sorted by ascending order of the creation moment.
  • POST Order to be delivered.
  • PUT Order status from "PENDING" to "DELIVERED".

Sample Valid JSON Request Body

POST -> /orders

{
	"id": 7,
	"address": "Avenida Paulista, 1500",
	"latitude": -23.56168,
	"longitude": -46.656139,
	"products": [
		{
			"id": 2
		},
		{
			"id": 5
		}
	]
}

Run in Insomnia}

It's important to mention that this is one of the applications from the DsDelivery System

In order to explore the others, feel free to click on the link below:

Requirements

For building and running the application you need:

๐Ÿ‘ท Installation

To install this application, run the following commands:

git clone https://github.com/iamgrodrigues/dsdelivery-api.git

If you have a SSH key registered in your Github account, clone the project using this command:

git clone [email protected]:iamgrodrigues/dsdelivery-api.git

๐Ÿƒ Getting Started

Running the Application Locally

There are several ways to run a Spring Boot application on your local machine. One way is to execute the main method in the com.iamgrodrigues.dsdeliveryapi.DsDeliveryApiApplication class from your IDE.

Alternatively you can use the Spring Boot Maven plugin like so:

mvn spring-boot:run

After the above command, you can navigate to the following address to see the project up and runnig:

http://localhost:8080/orders

Running Docker Container

Note: Skip this part if you have PostgreSQL installed

Once you've installed Docker, run the following command: that will start up the PostgreSQL container on 5432:5432 port, set up enviroment variables for user and password, and create a database called dsdelivery.

docker run --name dsdelivery-db -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=1234567 -e POSTGRES_DB=dsdelivery postgres

Create Tables and Populate the Database

Note: If you already have PostgreSQL installed on your machine, skip the docker related commands.

Run the following command to get inside of the docker container:

docker run -it --rm --net=host postgres /bin/bash

Change the active profile on the application.properties file to dev, uncomment the first four lines on the application-dev.properties file, and then restart the application. Once the application is up, a create.sql file will be created on the root project folder. Copy its contents, and paste it after the following command.

psql -h localhost -U postgres dsdelivery

In order to populate the database, you must copy the contents of the data.sql file and paste it after the above command.

Status Codes

DsDelivery returns the following status codes in its API:

Status Code Description
200 OK
201 CREATED
400 BAD REQUEST
500 INTERNAL SERVER ERROR

Error handling will be added soon.

๐Ÿ“ฎ Faq

Question: What are the tecnologies used in this project?

Answer: The tecnologies used in this project are Java + Spring Boot and PostgreSQL.

๐Ÿ› Issues

Feel free to file a new issue with a respective title and description on the the DsDelivery API repository. If you already found a solution to your problem, I would love to review your pull request! Have a look at our contribution guidelines to find out about the coding standards.

๐ŸŽ‰ Contributing

Check out the contributing page to see the best places to file issues, start discussions and begin contributing.

๐Ÿ“• License

Released in 2021. This project is under the MIT license.

Made with love by Guilherme Rodrigues ๐Ÿ’š๐Ÿš€

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.