demo/Java-Python/java_fs_demo/src/main/java/com/revature/App.java
<reponame>brianAray/220516-Python-with-Automationpackage com.revature;

import com.revature.controller.ItemController;
import com.revature.controller.SupplierController;
import com.revature.repository.ItemDao;
import com.revature.repository.SupplierDao;
import com.revature.repository.entities.ItemEntity;
import com.revature.service.ItemService;
import com.revature.service.SupplierService;
import com.revature.util.ConnectionFactory;

import io.cucumber.java.bs.I;
import io.javalin.Javalin;
import io.javalin.apibuilder.ApiBuilder;
import io.javalin.http.staticfiles.Location;

import static io.javalin.apibuilder.ApiBuilder.*;

public class App 
{
    public static void main( String[] args )
    {
        ItemDao iDao = new ItemDao();
        SupplierDao sDao = new SupplierDao();

        ItemService itemService = new ItemService();
        SupplierService supplierService = new SupplierService();

        itemService.setItemDao(iDao);
        supplierService.setSupplierDao(sDao);

        itemService.setSupplierService(supplierService);
        supplierService.setItemService(itemService);

        ItemController.setItemService(itemService);
        SupplierController.setSupplierService(supplierService);



        Javalin app = Javalin.create(
            config -> {
                config.addStaticFiles("src/main/resources/public", Location.EXTERNAL);
            }
        );

        app.start(9090);

        app.get("/", ctx -> {
            ctx.redirect("index.html");
        });

        app.routes(() -> {
            path("item", () -> {
                get("all", ItemController.allItemsHandler);
                get("{id}", ItemController.getItem);
            });
            path("supplier", () -> {
                get("all", SupplierController.allSuppliers);
                get("{id}", SupplierController.getSupplier);
            });
        });
    }

}
