mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2025-04-29 16:30:29 +05:30
add config for the frontend
This commit is contained in:
parent
83dc2e5833
commit
52370036e3
@ -37,3 +37,6 @@ hibernate.connection.driver_class:org.postgresql.Driver
|
|||||||
hibernate.dialect:org.hibernate.dialect.PostgreSQLDialect
|
hibernate.dialect:org.hibernate.dialect.PostgreSQLDialect
|
||||||
hibernate.connection.username:piped
|
hibernate.connection.username:piped
|
||||||
hibernate.connection.password:changeme
|
hibernate.connection.password:changeme
|
||||||
|
# Frontend configuration
|
||||||
|
frontend.statusPageUrl:https://kavin.rocks
|
||||||
|
frontend.donationUrl:https://kavin.rocks
|
@ -52,6 +52,12 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return getErrorResponse(e, request.getPath());
|
return getErrorResponse(e, request.getPath());
|
||||||
}
|
}
|
||||||
|
})).map(GET, "/config", AsyncServlet.ofBlocking(executor, request -> {
|
||||||
|
try {
|
||||||
|
return getJsonResponse(ResponseHelper.configResponse(), "no-store");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return getErrorResponse(e, request.getPath());
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
.map(GET, "/version", AsyncServlet.ofBlocking(executor, request -> getRawResponse(Constants.VERSION.getBytes(UTF_8), "text/plain", "no-store")))
|
.map(GET, "/version", AsyncServlet.ofBlocking(executor, request -> getRawResponse(Constants.VERSION.getBytes(UTF_8), "text/plain", "no-store")))
|
||||||
.map(HttpMethod.OPTIONS, "/*", request -> HttpResponse.ofCode(200))
|
.map(HttpMethod.OPTIONS, "/*", request -> HttpResponse.ofCode(200))
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package me.kavin.piped.consts;
|
package me.kavin.piped.consts;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
import me.kavin.piped.utils.PageMixin;
|
import me.kavin.piped.utils.PageMixin;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
@ -67,6 +69,8 @@ public class Constants {
|
|||||||
|
|
||||||
public static final Object2ObjectOpenHashMap<String, String> hibernateProperties = new Object2ObjectOpenHashMap<>();
|
public static final Object2ObjectOpenHashMap<String, String> hibernateProperties = new Object2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
|
public static final ObjectNode frontendProperties = mapper.createObjectNode();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Properties prop = new Properties();
|
Properties prop = new Properties();
|
||||||
try {
|
try {
|
||||||
@ -101,6 +105,8 @@ public class Constants {
|
|||||||
String key = String.valueOf(_key), value = String.valueOf(_value);
|
String key = String.valueOf(_key), value = String.valueOf(_value);
|
||||||
if (key.startsWith("hibernate"))
|
if (key.startsWith("hibernate"))
|
||||||
hibernateProperties.put(key, value);
|
hibernateProperties.put(key, value);
|
||||||
|
else if (key.startsWith("frontend"))
|
||||||
|
frontendProperties.put(key.replace("frontend.", ""), value);
|
||||||
});
|
});
|
||||||
|
|
||||||
// transform hibernate properties for legacy configurations
|
// transform hibernate properties for legacy configurations
|
||||||
|
@ -67,6 +67,10 @@ import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper
|
|||||||
|
|
||||||
public class ResponseHelper {
|
public class ResponseHelper {
|
||||||
|
|
||||||
|
public static byte[] configResponse() throws Exception {
|
||||||
|
return mapper.writeValueAsBytes(Constants.frontendProperties);
|
||||||
|
}
|
||||||
|
|
||||||
public static byte[] streamsResponse(String videoId) throws Exception {
|
public static byte[] streamsResponse(String videoId) throws Exception {
|
||||||
|
|
||||||
final var futureStream = Multithreading.supplyAsync(() -> {
|
final var futureStream = Multithreading.supplyAsync(() -> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user