Coder Social home page Coder Social logo

kaiburr-task1's Introduction

Task 1

๐ŸŒ ๐Ÿš€ LIVE APP

NOTE: README First

Requirements

  • Java
  • Maven
  • Spring Boot (Framework)
  • MongoDB
  • Docker

Dependencies

  • spring-boot-starter-web
  • spring-boot-starter-data-mongodb
  • spring-boot-maven-plugin

Building steps

  1. Open the folder /task1 in your favourite IDE ( VS Code โค๏ธ) Wait for few minutes while the IDE loads and completes necessary pre-build tasks.

  2. Run mvn clean install This will build and install the artifacts in to the local repository. Required jar file will be created inside /target folder.

  3. Run the application by clicking Run option or pressing F9 SpringBoot application server will load and start on port 8080 of the localhost.

Rest API Endpoints and Resources

Rest API Endpoint is mapped to http://127.0.0.1:8080/servers/

  • PUT a server http://127.0.0.1:8080/servers/createServer Accept "server" object in body in json format.

  • GET servers http://127.0.0.1:8080/servers/getServer Returns a list of "server" objects.

  • GET server by ID http://127.0.0.1:8080/servers/getServer?id=<ID> Returns a "server" object matching with ID.

  • GET servers by Name http://127.0.0.1:8080/servers/getServer?name=<Nmae> Returns a list of "server" objects matching with Name.

  • DELETE server http://127.0.0.1:8080/servers/deleteServer?id=<ID> Deletes a "server" object matching with ID.

RestController interface extends MongoRepository

List<Server> findAll();
    
Optional<Server> findById(String Id);
    
void createOrUpdateServer(Server server);
    
void deleteServerById(String Id);
    
List<Server> findByName(String name);

Containerizing the app

Dockerfile contains all the commands required to build the app image

FROM openjdk:8-alpine EXPOSE 8080 ADD target/demo.jar demo.jar ENTRYPOINT ["java", "-Dspring.data.mongodb.uri=mongodb://mongod:27017/servers", "-jar", "/demo.jar"]

  1. Run the following command to build docker image sudo docker build -t <container_image_name> . This will create the app container image and add to you local repository.

  2. To Run the app from container, run the following command sudo docker run -p 80:80 <container_image_name> SpringBoot application server will load and start on port 8080 of the localhost You will see application logs in the terminal.

Note: The docker-compose part is Documented in Task3

Consuming APIs

Using Postman

Run the following created collection to Test and consume the APIs

Run in Postman

NOTE: The above collection is created and tested for http://127.0.0.1:8080/servers/ endpoint

Screenshots

PutPostManIO

GetAllServerPostManIO

GetServByIdPostManIO

GetServByNamePostManIO

DelPostManIO

Using WebUIForms

NOTE: This part is Documented in Task4

kaiburr-task1's People

Contributors

rahulkushwah-0 avatar

Watchers

 avatar

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.