Giter Site home page Giter Site logo

imdb-cast-api's Introduction

imdb-cast-api

Cast API for the IMDB SmartThings project.

Cast API is a Spring Boot application backed by a MySQL database.

This API leverages a few packages on top of Spring Boot for ease of development:

  • Project Lombok: provides annotations to replace boilerplate code in POJOs, such as constructors, getters & setters, etc.
  • Spring Data REST: automagically implements a fully-fledged RESTful API based on a data Repository with simple annotations. This REST API supports sorting & pagination out of the box.

Build

Cast API uses the Gradle build tool. It is recommended to use the Gradle Wrapper to ensure cross-platform compatibility and enforce a validated version.

  • For macOS: ./gradlew <task>
  • For Windows: gradlew <task>

Here are the various tasks and how to use them:

Gradle task Description
build Complete build task - compiles main and test, runs the test suite and validate coverage, analyzes code with PMD, and builds the .jar
test Compiles the test code, and runs the test suite, validates coverage, and performs PMD analysis.
pmdMain Analyzes main code with PMD.
pmdTest Analyzes test code with PMD.

You can additionally exclude some parts of a task with the -x flag. For example, gradlew build -x test will exclude all parts of the test task.

Deployments

Warning: The first deployment of the application will be slower than the subsequent deployments, because the application will seed the database.

Prerequisites

Before you can deploy the application:

  1. the executable .jar must be generated by running the build Gradle task
  2. the database must be deployed to Docker

Database

The database is only meant to be deployed to Docker. The Dockerfile and a SQL script to generate the schema are located in .docker/. To deploy the MySQL database to Docker:

  1. Ensure that Docker is running on your system
  2. From the root of the imdb-cast-api project, run the following command:
docker-compose up cast-db --build

Local API deployment

Once you have executed the Gradle build task and deployed the MySQL database to Docker, you can deploy the Spring Boot application as such:

java -Dspring.profiles.active=local -jar ./build/libs/cast-<version>-.jar

Docker API deployment

Once you have executed the Gradle build task, you can deploy the Spring Boot application as such:

docker-compose up cast-api --build # if the database is already deployed

Usage

The application is accessible at the following base URLs:

Environment Base URL
Local http://localhost:8080
Docker http://localhost:5013

API Docs

Postman

For easy interaction with the API, you can import the Postman collection in ./postman.

HATEOAS

Spring Data REST publishes its data using HATEOAS, which uses the API responses and hypermedia to deliver a self- documenting API. You can start with:

curl -X GET http://localhost:8080/api/v1/cast # Local
curl -X GET http://localhost:5013/api/v1/cast # Docker

Spring Boot Actuator

You can also use the Spring Boot Actuator mappings endpoint to get a list of endpoints:

curl -X GET 'http://localhost:8080/actuator/mappings' # Local
curl -X GET 'http://localhost:5013/actuator/mappings' # Docker

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.