Skip to content

Commit

Permalink
dockerize api-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
flynnc3 committed Feb 9, 2023
1 parent 0d3473c commit 888e515
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 80 deletions.
7 changes: 1 addition & 6 deletions DeFi-Data-Engine/Api-Handler/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
Expand Down
3 changes: 3 additions & 0 deletions DeFi-Data-Engine/Api-Handler/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM maven:3.8.6-eclipse-temurin-17-alpine

ENV APP_NAME api-handler
ENV PORT 8080

EXPOSE ${PORT}

COPY ./ ./
RUN mvn clean package spring-boot:repackage -Dmaven.skip.test=true
Expand Down
2 changes: 1 addition & 1 deletion DeFi-Data-Engine/Api-Handler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>org.application</groupId>
<artifactId>api-handler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.1</version>
<name>api-handler</name>
<description>Lightweight application for retrieving generalized api calls.</description>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.stream.external.request.core.RequestFramework;
import org.stream.external.request.core.RequestManager;
import org.stream.external.request.types.RequestFramework;
import org.stream.external.request.types.RequestManager;

import jakarta.annotation.PostConstruct;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stream.external.request.core;
package org.stream.external.request.types;

import java.io.IOException;
import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stream.external.request.core;
package org.stream.external.request.types;

import java.io.File;
import java.io.FileInputStream;
Expand All @@ -10,6 +10,7 @@
import java.util.Set;

import org.reflections.Reflections;
import org.reflections.util.ConfigurationBuilder;

public class RequestManager {

Expand All @@ -18,7 +19,7 @@ public class RequestManager {

public static void initialize() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, URISyntaxException, IOException {
// load all templates
Reflections reflection = new Reflections("org.stream.external.request.types");
Reflections reflection = new Reflections(new ConfigurationBuilder().forPackages(RequestManager.class.getPackageName()));
Set<Class<? extends RequestFramework>> types = reflection.getSubTypesOf(RequestFramework.class);
for(Class<? extends RequestFramework> c : types) {
templates.put(c.getDeclaredConstructor().newInstance().getType(), c);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.application.apihandler.ApiHandlerApplication;
import org.json.JSONArray;
import org.json.JSONObject;
import org.stream.external.request.core.RequestFramework;

public class RequestParameterized extends RequestFramework {

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
package test.application.apihandler;

import java.util.HashMap;

import org.stream.external.request.types.RequestParameterized;

public class SampleBlockchainAddresses {

public static void main(String[] args) {
HashMap<String, String> properties = new HashMap<String, String>();
HashMap<String, String> headers = new HashMap<String, String>();
HashMap<String, String> tags = new HashMap<String, String>();

properties.put("page", "0");
properties.put("size", "50");

headers.put("accept", "application/json");
headers.put("x-amberdata-blockchain-id", "ethereum-mainnet");
headers.put("x-api-key", "UAK7ed69235426c360be22bfc2bde1809b6");

tags.put("-l", "50");
tags.put("-t", "incremental");

String[] path = {"payload", "records"};
String[] recursive_location = {"page"};
String recursive_replacement = null;

RequestParameterized request = new RequestParameterized("test",
"https://web3api.io/api/v2/addresses", new String[]{}, properties, headers, tags,
recursive_location, recursive_replacement, path, false, "", "", "", "");

request.request(new String[] {}, properties, headers);
}
// disabled for docker composition

// public static void main(String[] args) {
// HashMap<String, String> properties = new HashMap<String, String>();
// HashMap<String, String> headers = new HashMap<String, String>();
// HashMap<String, String> tags = new HashMap<String, String>();
//
// properties.put("page", "0");
// properties.put("size", "50");
//
// headers.put("accept", "application/json");
// headers.put("x-amberdata-blockchain-id", "ethereum-mainnet");
// headers.put("x-api-key", "UAK7ed69235426c360be22bfc2bde1809b6");
//
// tags.put("-l", "50");
// tags.put("-t", "incremental");
//
// String[] path = {"payload", "records"};
// String[] recursive_location = {"page"};
// String recursive_replacement = null;
//
// RequestParameterized request = new RequestParameterized("test",
// "https://web3api.io/api/v2/addresses", new String[]{}, properties, headers, tags,
// recursive_location, recursive_replacement, path, false, "", "", "", "");
//
// request.request(new String[] {}, properties, headers);
// }
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
package test.application.apihandler;

import java.util.HashMap;

import org.stream.external.request.types.RequestParameterized;

public class SampleMakerDAOProtocol {

public static void main(String[] args) {
HashMap<String, String> properties = new HashMap<String, String>();
HashMap<String, String> headers = new HashMap<String, String>();
HashMap<String, String> tags = new HashMap<String, String>();

properties.put("startDate", "2020-09-01T01:00:00");
properties.put("endDate", "2020-09-03T01:00:00");
properties.put("size", "900");

headers.put("accept", "application/json");
headers.put("x-api-key", "UAK7ed69235426c360be22bfc2bde1809b6");

tags.put("-l", "900");
tags.put("-t", "url");

String[] path = {"payload", "data"};
String[] recursive_location = {"payload", "metadata", "next"};
String recursive_replacement = null;

RequestParameterized request = new RequestParameterized("test",
"https://web3api.io/api/v2/defi/lending/makerdao/protocol", new String[]{}, properties, headers, tags,
recursive_location, recursive_replacement, path, false, "", "", "", "");

request.request(new String[] {}, properties, headers);
}
// disabled for docker composition

// public static void main(String[] args) {
// HashMap<String, String> properties = new HashMap<String, String>();
// HashMap<String, String> headers = new HashMap<String, String>();
// HashMap<String, String> tags = new HashMap<String, String>();
//
// properties.put("startDate", "2020-09-01T01:00:00");
// properties.put("endDate", "2020-09-03T01:00:00");
// properties.put("size", "900");
//
// headers.put("accept", "application/json");
// headers.put("x-api-key", "UAK7ed69235426c360be22bfc2bde1809b6");
//
// tags.put("-l", "900");
// tags.put("-t", "url");
//
// String[] path = {"payload", "data"};
// String[] recursive_location = {"payload", "metadata", "next"};
// String recursive_replacement = null;
//
// RequestParameterized request = new RequestParameterized("test",
// "https://web3api.io/api/v2/defi/lending/makerdao/protocol", new String[]{}, properties, headers, tags,
// recursive_location, recursive_replacement, path, false, "", "", "", "");
//
// request.request(new String[] {}, properties, headers);
// }
}

0 comments on commit 888e515

Please sign in to comment.