Add Event entity, CreateEventCommand, ports (CreateEventUseCase, EventRepository), and EventService with Clock injection for deterministic testing. Expiry date must be in the future. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48 lines
1.7 KiB
Java
48 lines
1.7 KiB
Java
package de.fete.config;
|
|
|
|
import java.io.IOException;
|
|
import java.time.Clock;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.core.io.ClassPathResource;
|
|
import org.springframework.core.io.Resource;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
import org.springframework.web.servlet.resource.PathResourceResolver;
|
|
|
|
/** Configures API path prefix and SPA static resource serving. */
|
|
@Configuration
|
|
public class WebConfig implements WebMvcConfigurer {
|
|
|
|
@Bean
|
|
Clock clock() {
|
|
return Clock.systemDefaultZone();
|
|
}
|
|
|
|
@Override
|
|
public void configurePathMatch(PathMatchConfigurer configurer) {
|
|
configurer.addPathPrefix("/api", c -> c.isAnnotationPresent(RestController.class));
|
|
}
|
|
|
|
@Override
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
registry.addResourceHandler("/**")
|
|
.addResourceLocations("classpath:/static/")
|
|
.resourceChain(true)
|
|
.addResolver(new PathResourceResolver() {
|
|
@Override
|
|
protected Resource getResource(String resourcePath,
|
|
Resource location) throws IOException {
|
|
Resource requested = location.createRelative(resourcePath);
|
|
if (requested.exists() && requested.isReadable()) {
|
|
return requested;
|
|
}
|
|
Resource index = new ClassPathResource("/static/index.html");
|
|
return (index.exists() && index.isReadable()) ? index : null;
|
|
}
|
|
});
|
|
}
|
|
}
|