mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-17 20:50:44 +00:00
Added full support for defining SPAs within the metadata for a route provider (both spa hosted path, and physical file path)
This commit is contained in:
@ -135,14 +135,16 @@ public class QApplicationJavalinServer
|
||||
{
|
||||
if(resource != null)
|
||||
{
|
||||
config.staticFiles.add(staticFileConfig -> {
|
||||
config.staticFiles.add(staticFileConfig ->
|
||||
{
|
||||
staticFileConfig.hostedPath = this.frontendMaterialDashboardHostedPath;
|
||||
staticFileConfig.directory = "/material-dashboard-overlay";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
config.staticFiles.add(staticFileConfig -> {
|
||||
config.staticFiles.add(staticFileConfig ->
|
||||
{
|
||||
staticFileConfig.hostedPath = this.frontendMaterialDashboardHostedPath;
|
||||
staticFileConfig.directory = "/material-dashboard";
|
||||
});
|
||||
@ -212,10 +214,6 @@ public class QApplicationJavalinServer
|
||||
config.router.apiBuilder(javalinEndpointGroup);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// If the additional route provider has an SPA root defined, add it to the Javalin config. //
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
routeProvider.acceptJavalinConfig(config);
|
||||
}
|
||||
});
|
||||
|
@ -34,8 +34,6 @@ import io.javalin.config.JavalinConfig;
|
||||
*******************************************************************************/
|
||||
public abstract class QJavalinRouteProvider
|
||||
{
|
||||
private String spaRootPath = null;
|
||||
|
||||
/***************************************************************************
|
||||
** For initial setup when server boots, set the qInstance - but also,
|
||||
** e.g., for development, to do a hot-swap.
|
||||
@ -73,11 +71,10 @@ public abstract class QJavalinRouteProvider
|
||||
** accept the Javalin service object, to perform whatever setup you need,
|
||||
** such as setting up before/after handlers.
|
||||
***************************************************************************/
|
||||
public void acceptJavalinService(Javalin service)
|
||||
public void acceptJavalinService(Javalin service)
|
||||
{
|
||||
/////////////////////
|
||||
// noop at default //
|
||||
/////////////////////
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,14 +32,12 @@ import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
|
||||
*******************************************************************************/
|
||||
public class JavalinRouteProviderMetaData implements QMetaDataObject
|
||||
{
|
||||
private String hostedPath;
|
||||
private String spaRootPath;
|
||||
|
||||
private String fileSystemPath;
|
||||
private String processName;
|
||||
|
||||
private List<String> methods;
|
||||
|
||||
private String hostedPath;
|
||||
private String spaRootPath;
|
||||
private String spaRootFile;
|
||||
private String fileSystemPath;
|
||||
private String processName;
|
||||
private List<String> methods;
|
||||
private QCodeReference routeAuthenticator;
|
||||
|
||||
|
||||
@ -208,6 +206,7 @@ public class JavalinRouteProviderMetaData implements QMetaDataObject
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for spaRootPath
|
||||
*******************************************************************************/
|
||||
@ -238,4 +237,38 @@ public class JavalinRouteProviderMetaData implements QMetaDataObject
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Getter for spaRootFile
|
||||
* @see #withSpaRootFile(String)
|
||||
*******************************************************************************/
|
||||
public String getSpaRootFile()
|
||||
{
|
||||
return (this.spaRootFile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Setter for spaRootFile
|
||||
* @see #withSpaRootFile(String)
|
||||
*******************************************************************************/
|
||||
public void setSpaRootFile(String spaRootFile)
|
||||
{
|
||||
this.spaRootFile = spaRootFile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Fluent setter for spaRootFile
|
||||
* @param spaRootFile TODO document this property
|
||||
* @return this
|
||||
*******************************************************************************/
|
||||
public JavalinRouteProviderMetaData withSpaRootFile(String spaRootFile)
|
||||
{
|
||||
this.spaRootFile = spaRootFile;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -48,15 +48,17 @@ import static com.kingsrook.qqq.backend.core.logging.LogUtils.logPair;
|
||||
*******************************************************************************/
|
||||
public class SimpleFileSystemDirectoryRouter extends QJavalinRouteProvider
|
||||
{
|
||||
private QCodeReference routeAuthenticator;
|
||||
private QInstance qInstance;
|
||||
private final String fileSystemPath;
|
||||
private final String hostedPath;
|
||||
|
||||
public static final String LOAD_STATIC_FILES_FROM_JAR_PROPERTY = "qqq.javalin.enableStaticFilesFromJar";
|
||||
private static final QLogger LOG = QLogger.getLogger(SimpleFileSystemDirectoryRouter.class);
|
||||
public static boolean loadStaticFilesFromJar = false;
|
||||
private final String fileSystemPath;
|
||||
private final String hostedPath;
|
||||
private QCodeReference routeAuthenticator;
|
||||
private QInstance qInstance;
|
||||
private String spaRootPath;
|
||||
private String spaRootFile;
|
||||
|
||||
|
||||
public static final String LOAD_STATIC_FILES_FROM_JAR_PROPERTY = "qqq.javalin.enableStaticFilesFromJar";
|
||||
public static boolean loadStaticFilesFromJar = false;
|
||||
|
||||
/*******************************************************************************
|
||||
** Constructor
|
||||
@ -94,6 +96,8 @@ public class SimpleFileSystemDirectoryRouter extends QJavalinRouteProvider
|
||||
public SimpleFileSystemDirectoryRouter(JavalinRouteProviderMetaData routeProvider)
|
||||
{
|
||||
this(routeProvider.getHostedPath(), routeProvider.getFileSystemPath());
|
||||
setSpaRootPath(routeProvider.getSpaRootPath());
|
||||
setSpaRootFile(routeProvider.getSpaRootFile());
|
||||
setRouteAuthenticator(routeProvider.getRouteAuthenticator());
|
||||
}
|
||||
|
||||
@ -200,6 +204,10 @@ public class SimpleFileSystemDirectoryRouter extends QJavalinRouteProvider
|
||||
@Override
|
||||
public void acceptJavalinConfig(JavalinConfig config)
|
||||
{
|
||||
if(this.getSpaRootPath() != null && !this.getSpaRootPath().isEmpty())
|
||||
{
|
||||
config.spaRoot.addFile(this.spaRootPath, this.spaRootFile);
|
||||
}
|
||||
config.staticFiles.add(this::handleJavalinStaticFileConfig);
|
||||
}
|
||||
|
||||
@ -253,4 +261,74 @@ public class SimpleFileSystemDirectoryRouter extends QJavalinRouteProvider
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Getter for spaRootPath
|
||||
* @see #withSpaRootPath(String)
|
||||
*******************************************************************************/
|
||||
public String getSpaRootPath()
|
||||
{
|
||||
return (this.spaRootPath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Setter for spaRootPath
|
||||
* @see #withSpaRootPath(String)
|
||||
*******************************************************************************/
|
||||
public void setSpaRootPath(String spaRootPath)
|
||||
{
|
||||
this.spaRootPath = spaRootPath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Fluent setter for spaRootPath
|
||||
* @param spaRootPath TODO document this property
|
||||
* @return this
|
||||
*******************************************************************************/
|
||||
public SimpleFileSystemDirectoryRouter withSpaRootPath(String spaRootPath)
|
||||
{
|
||||
this.spaRootPath = spaRootPath;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Getter for spaRootFile
|
||||
* @see #withSpaRootFile(String)
|
||||
*******************************************************************************/
|
||||
public String getSpaRootFile()
|
||||
{
|
||||
return (this.spaRootFile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Setter for spaRootFile
|
||||
* @see #withSpaRootFile(String)
|
||||
*******************************************************************************/
|
||||
public void setSpaRootFile(String spaRootFile)
|
||||
{
|
||||
this.spaRootFile = spaRootFile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Fluent setter for spaRootFile
|
||||
* @param spaRootFile TODO document this property
|
||||
* @return this
|
||||
*******************************************************************************/
|
||||
public SimpleFileSystemDirectoryRouter withSpaRootFile(String spaRootFile)
|
||||
{
|
||||
this.spaRootFile = spaRootFile;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user