[FIX] set work again

This commit is contained in:
Edouard DUPIN 2025-01-06 00:27:09 +01:00
parent 762a1aeced
commit db1e387ac8
11 changed files with 2190 additions and 1929 deletions

View File

@ -20,7 +20,7 @@
<dependency>
<groupId>kangaroo-and-rabbit</groupId>
<artifactId>archidata</artifactId>
<version>0.20.0</version>
<version>0.20.2</version>
</dependency>
<!-- Loopback of logger JDK logging API to SLF4J -->
<dependency>

View File

@ -39,7 +39,6 @@ import org.kar.karusic.migration.Migration20240225;
import org.kar.karusic.migration.Migration20240226;
import org.kar.karusic.migration.Migration20240907;
import org.kar.karusic.migration.Migration20250104;
import org.kar.karusic.migration.Migration20250105;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.bridge.SLF4JBridgeHandler;
@ -50,15 +49,15 @@ public class WebLauncher {
final static Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class);
protected UpdateJwtPublicKey keyUpdater = null;
protected HttpServer server = null;
public WebLauncher() {
ConfigBaseVariable.bdDatabase = "karusic";
}
private static URI getBaseURI() {
return UriBuilder.fromUri(ConfigBaseVariable.getlocalAddress()).build();
}
public void migrateDB() throws Exception {
WebLauncher.LOGGER.info("Create migration engine");
final MigrationEngine migrationEngine = new MigrationEngine();
@ -70,21 +69,20 @@ public class WebLauncher {
migrationEngine.add(new Migration20240226());
migrationEngine.add(new Migration20240907());
migrationEngine.add(new Migration20250104());
migrationEngine.add(new Migration20250105());
WebLauncher.LOGGER.info("Migrate the DB [START]");
migrationEngine.migrateWaitAdmin(new DbConfig());
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
}
public static void main(final String[] args) throws Exception {
// Loop-back of logger JDK logging API to SLF4J
LogManager.getLogManager().reset();
SLF4JBridgeHandler.install();
WebLauncher.LOGGER.info("[START] application wake UP");
final WebLauncher launcher = new WebLauncher();
launcher.migrateDB();
launcher.process();
WebLauncher.LOGGER.info("end-configure the server & wait finish process:");
Thread.currentThread().join();
@ -92,7 +90,7 @@ public class WebLauncher {
launcher.stopOther();
WebLauncher.LOGGER.info("STOP the REST server:");
}
public void plop(final String aaa) {
// List available Image Readers
WebLauncher.LOGGER.trace("Available Image Readers:");
@ -103,7 +101,7 @@ public class WebLauncher {
WebLauncher.LOGGER.trace("Reader CN: " + reader.getOriginatingProvider().getPluginClassName());
// ImageIO.deregisterServiceProvider(reader.getOriginatingProvider());
}
// List available Image Writers
WebLauncher.LOGGER.trace("\nAvailable Image Writers:");
final Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName(aaa);
@ -113,9 +111,9 @@ public class WebLauncher {
WebLauncher.LOGGER.trace("Writer CN: " + writer.getOriginatingProvider().getPluginClassName());
}
}
public void process() throws InterruptedException, DataAccessException {
ImageIO.scanForPlugins();
plop("jpeg");
plop("png");
@ -125,7 +123,7 @@ public class WebLauncher {
// Configure resources
// ===================================================================
final ResourceConfig rc = new ResourceConfig();
// add multipart models ..
rc.register(MultiPartFeature.class);
// global authentication system
@ -145,17 +143,17 @@ public class WebLauncher {
rc.register(TrackResource.class);
rc.register(DataResource.class);
rc.register(ProxyResource.class);
rc.register(HealthCheck.class);
rc.register(Front.class);
ContextGenericTools.addJsr310(rc);
// add jackson to be discover when we are ins standalone server
rc.register(JacksonFeature.class);
// enable this to show low level request
// rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.WARNING.getName());
// System.out.println("Connect on the BDD:");
// System.out.println(" getDBHost: '" + ConfigVariable.getDBHost() + "'");
// System.out.println(" getDBPort: '" + ConfigVariable.getDBPort() + "'");
@ -173,13 +171,13 @@ public class WebLauncher {
serverLink.shutdownNow();
}
}, "shutdownHook"));
// ===================================================================
// start periodic update of the token ...
// ===================================================================
this.keyUpdater = new UpdateJwtPublicKey();
this.keyUpdater.start();
// ===================================================================
// run JERSEY
// ===================================================================
@ -191,14 +189,14 @@ public class WebLauncher {
e.printStackTrace();
}
}
public void stop() {
if (this.server != null) {
this.server.shutdownNow();
this.server = null;
}
}
public void stopOther() {
this.keyUpdater.kill();
try {

View File

@ -1,31 +0,0 @@
package org.kar.karusic.migration;
import org.kar.archidata.migration.MigrationSqlStep;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Migration20250105 extends MigrationSqlStep {
private static final Logger LOGGER = LoggerFactory.getLogger(Migration20240907.class);
public static final int KARSO_INITIALISATION_ID = 1;
@Override
public String getName() {
return "migration-2025-01-05: remove old UUID";
}
@Override
public void generateStep() throws Exception {
// addAction("""
// ALTER TABLE `data` DROP INDEX `PRIMARY`;
// """);
// addAction("""
// ALTER TABLE `data` CHANGE `id` `uuid` binary(16) DEFAULT (UUID_TO_BIN(UUID(), TRUE));
// """);
// addAction("""
// ALTER TABLE `data` ADD PRIMARY KEY `uuid` (`uuid`);
// """);
}
}

View File

@ -1,10 +1,9 @@
package test.kar.karusic;
import java.util.UUID;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
import org.kar.archidata.tools.ConfigBaseVariable;
@ -21,8 +20,6 @@ public class TestBase {
static WebLauncherTest webInterface = null;
static RESTApi api = null;
private static UUID idTest;
@BeforeAll
public static void configureWebServer() throws Exception {
ConfigureDb.configure();
@ -45,4 +42,9 @@ public class TestBase {
ConfigureDb.clear();
}
@Test
public static void TestEmpty() throws Exception {
}
}

View File

@ -1,61 +0,0 @@
package test.kar.karusic;
import static org.bson.codecs.configuration.CodecRegistries.fromProviders;
import static org.bson.codecs.configuration.CodecRegistries.fromRegistries;
import java.io.IOException;
import org.bson.codecs.configuration.CodecRegistry;
import org.bson.codecs.pojo.PojoCodecProvider;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
import org.kar.karusic.model.Track;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.mongodb.ConnectionString;
import com.mongodb.MongoClientSettings;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
@ExtendWith(StepwiseExtension.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class TestMongoDb {
final static private Logger LOGGER = LoggerFactory.getLogger(TestMongoDb.class);
@BeforeAll
public static void configureWebServer() throws Exception {}
@AfterAll
public static void removeDataBase() throws IOException {
}
@Order(1)
@Test
public void testCreateTable() throws Exception {
final ConnectionString connectionString = new ConnectionString("mongodb://localhost:27017");// System.getProperty("mongodb.uri"));
// Configure the CodecRegistry to include a codec to handle the translation to and from BSON for our POJOs.
final CodecRegistry pojoCodecRegistry = fromProviders(PojoCodecProvider.builder().automatic(true).build());
// Add the default codec registry, which contains all the default codecs. They can handle all the major types in
// Java-like Boolean, Double, String, BigDecimal, etc.
final CodecRegistry codecRegistry = fromRegistries(MongoClientSettings.getDefaultCodecRegistry(), pojoCodecRegistry);
// Wrap all my settings together using MongoClientSettings.
final MongoClientSettings clientSettings = MongoClientSettings.builder().applyConnectionString(connectionString).codecRegistry(codecRegistry).build();
// Initiate the connection with MongoDB.
try (MongoClient mongoClient = MongoClients.create(clientSettings)) {
final MongoDatabase db = mongoClient.getDatabase("sample_training");
final MongoCollection<Track> grades = db.getCollection("Track", Track.class);
}
}
}

View File

@ -1,34 +1,12 @@
package test.kar.karusic;
import org.kar.archidata.tools.ConfigBaseVariable;
import org.kar.karusic.WebLauncher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WebLauncherTest extends WebLauncher {
final private static Logger LOGGER = LoggerFactory.getLogger(WebLauncherTest.class);
public WebLauncherTest() {
LOGGER.debug("Configure REST system");
// for local test:
ConfigBaseVariable.apiAdress = "http://127.0.0.1:13212/test/api/";
// Enable the test mode permit to access to the test token (never use it in production).
ConfigBaseVariable.testMode = "true";
// for the test we a in memory sqlite..
if (true) {
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
ConfigBaseVariable.dbType = "sqlite";
ConfigBaseVariable.dbHost = "memory";
// for test we need to connect all time the DB
ConfigBaseVariable.dbKeepConnected = "true";
}
} else {
// Enable this if you want to access to a local MySQL base to test with an adminer
ConfigBaseVariable.bdDatabase = "test_db";
ConfigBaseVariable.dbPort = "3309";
ConfigBaseVariable.dbUser = "root";
// ConfigBaseVariable.dbPassword = "password";
}
}
public WebLauncherTest() {}
}

View File

@ -1,6 +1,6 @@
{
"display": "__DEVELOPMENT__",
"version": "__VERSION__",
"commit": "__COMMIT__",
"date": "__DATE__"
}
"display": "2025-01-06",
"version": "0.0.1-dev\n - 2025-01-06T00:19:36+01:00",
"commit": "0.0.1-dev\n",
"date": "2025-01-06T00:19:36+01:00"
}

View File

@ -28,13 +28,13 @@
"*.{ts,tsx,js,jsx,json}": "prettier --write"
},
"dependencies": {
"@chakra-ui/anatomy": "2.3.4",
"@chakra-ui/cli": "3.2.5",
"@chakra-ui/react": "3.2.5",
"@chakra-ui/theme-tools": "2.2.6",
"@dnd-kit/core": "6.3.1",
"@dnd-kit/modifiers": "9.0.0",
"@dnd-kit/sortable": "10.0.0",
"@chakra-ui/anatomy": "2.2.2",
"@chakra-ui/cli": "2.4.1",
"@chakra-ui/react": "2.8.2",
"@chakra-ui/theme-tools": "2.1.2",
"@dnd-kit/core": "6.1.0",
"@dnd-kit/modifiers": "7.0.0",
"@dnd-kit/sortable": "8.0.0",
"@dnd-kit/utilities": "3.2.2",
"@emotion/react": "11.14.0",
"@emotion/styled": "11.14.0",
@ -44,21 +44,21 @@
"css-mediaquery": "0.1.2",
"dayjs": "1.11.13",
"history": "5.3.0",
"react": "19.0.0",
"react": "18.3.1",
"react-color-palette": "7.3.0",
"react-currency-input-field": "3.9.0",
"react-currency-input-field": "3.8.0",
"react-custom-scrollbars": "4.2.1",
"react-day-picker": "9.5.0",
"react-dom": "19.0.0",
"react-error-boundary": "5.0.0",
"react-focus-lock": "2.13.5",
"react-icons": "5.4.0",
"react-day-picker": "9.1.1",
"react-dom": "18.3.1",
"react-error-boundary": "4.0.13",
"react-focus-lock": "2.13.2",
"react-icons": "5.3.0",
"react-popper": "2.3.0",
"react-router-dom": "7.1.1",
"react-select": "5.9.0",
"react-simple-keyboard": "3.8.33",
"react-router-dom": "6.26.2",
"react-select": "5.8.1",
"react-simple-keyboard": "3.8.3",
"react-sticky-el": "2.1.1",
"react-use": "17.6.0",
"react-use": "17.5.1",
"react-use-draggable-scroll": "0.4.7",
"react-virtuoso": "4.12.3",
"ts-pattern": "5.6.0",
@ -67,33 +67,33 @@
"zustand": "5.0.2"
},
"devDependencies": {
"@chakra-ui/styled-system": "2.12.0",
"@playwright/test": "1.49.1",
"@storybook/addon-actions": "8.4.7",
"@storybook/addon-essentials": "8.4.7",
"@storybook/addon-links": "8.4.7",
"@storybook/addon-mdx-gfm": "8.4.7",
"@storybook/react": "8.4.7",
"@storybook/react-vite": "8.4.7",
"@storybook/theming": "8.4.7",
"@testing-library/jest-dom": "6.6.3",
"@testing-library/react": "16.1.0",
"@chakra-ui/styled-system": "2.9.2",
"@playwright/test": "1.47.2",
"@storybook/addon-actions": "8.3.2",
"@storybook/addon-essentials": "8.3.2",
"@storybook/addon-links": "8.3.2",
"@storybook/addon-mdx-gfm": "8.3.2",
"@storybook/react": "8.3.2",
"@storybook/react-vite": "8.3.2",
"@storybook/theming": "8.3.2",
"@testing-library/jest-dom": "6.5.0",
"@testing-library/react": "16.0.1",
"@testing-library/user-event": "14.5.2",
"@trivago/prettier-plugin-sort-imports": "5.2.1",
"@types/jest": "29.5.14",
"@types/node": "22.10.5",
"@types/react": "19.0.2",
"@types/react-dom": "19.0.2",
"@types/react-sticky-el": "2.1.0",
"@typescript-eslint/eslint-plugin": "8.19.0",
"@typescript-eslint/parser": "8.19.0",
"@vitejs/plugin-react": "4.3.4",
"eslint": "9.17.0",
"@trivago/prettier-plugin-sort-imports": "4.3.0",
"@types/jest": "29.5.13",
"@types/node": "22.5.5",
"@types/react": "18.3.8",
"@types/react-dom": "18.3.0",
"@types/react-sticky-el": "1.0.7",
"@typescript-eslint/eslint-plugin": "8.6.0",
"@typescript-eslint/parser": "8.6.0",
"@vitejs/plugin-react": "4.3.1",
"eslint": "9.11.0",
"eslint-plugin-codeceptjs": "1.3.0",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-react": "7.37.3",
"eslint-plugin-react-hooks": "5.1.0",
"eslint-plugin-storybook": "0.11.2",
"eslint-plugin-import": "2.30.0",
"eslint-plugin-react": "7.36.1",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-storybook": "0.8.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"knip": "5.41.1",
@ -108,4 +108,4 @@
"vite": "6.0.7",
"vitest": "2.1.8"
}
}
}

3766
front/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -15,6 +15,8 @@ import {
getRestConfig,
useSessionServiceWrapped,
} from '@/service/session';
import { Album, Artist, Gender, Track } from '@/back-api';
import { DataStoreType } from '@/utils/data-store';
export type ServiceContextType = {
session: SessionServiceProps;
@ -26,24 +28,28 @@ export type ServiceContextType = {
};
const emptyStore = {
data: [],
isLoading: true,
get: (_value, _key) => {
console.error('!!! WTF !!!');
return undefined;
},
gets: (_value, _key) => {
console.error('!!! WTF !!!');
return [];
},
error: undefined,
update: (request: Promise<{ id: number; artists: number[]; track?: number | undefined; createdAt?: string | undefined; updatedAt?: string | undefined; deleted?: boolean | undefined; name?: string | undefined; description?: string | undefined; covers?: string[] | undefined; genderId?: number | undefined; albumId?: number | undefined; dataId?: string | undefined; }>, key?: string): void => {
console.error('!!! WTF !!!');
},
remove: (id: number | string, request: Promise<void>, key?: string): void => {
console.error('!!! WTF !!!');
}
function emptyStore<TYPE>(): DataStoreType<TYPE> {
return {
data: [] as TYPE[],
isLoading: true,
get: (_value: any, _key: any) => {
console.error('!!! WTF !!!');
return undefined;
},
gets: (_value: any, _key: any) => {
console.error('!!! WTF !!!');
return [];
},
error: undefined,
update: (_request: Promise<TYPE>, _key?: string) => {
console.error('!!! WTF !!!');
return new Promise((resolve, reject) => { reject("fail") });
},
updateRaw: (_data: TYPE, _key?: string) => { },
remove: (_id: number | string, _request: Promise<void>, _key?: string): void => {
console.error('!!! WTF !!!');
}
};
}
export const ServiceContext = createContext<ServiceContextType>({
@ -56,16 +62,16 @@ export const ServiceContext = createContext<ServiceContextType>({
getRestConfig: getRestConfig,
},
track: {
store: emptyStore,
store: emptyStore<Track>(),
},
artist: {
store: emptyStore,
store: emptyStore<Artist>(),
},
album: {
store: emptyStore,
store: emptyStore<Album>(),
},
gender: {
store: emptyStore,
store: emptyStore<Gender>(),
},
activePlaylist: {
playTrackList: [],

View File

@ -2,10 +2,13 @@
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ES2021"],
"lib": [
"DOM",
"DOM.Iterable",
"ES2021"
],
"module": "ESNext",
"skipLibCheck": true,
// Bundler mode
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
@ -13,7 +16,6 @@
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
// Linting
"allowJs": false,
"strict": false,
@ -22,13 +24,28 @@
"esModuleInterop": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
"@/*": [
"src/*"
]
},
"typeRoots": ["./node_modules/@types", "./src/types"],
"typeRoots": [
"./node_modules/@types",
"./src/types"
],
"incremental": true,
"strictNullChecks": true
},
"include": ["next-env.d.ts", "src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules"],
"references": [{ "path": "./tsconfig.node.json" }]
}
"include": [
"next-env.d.ts",
"src/**/*.ts",
"src/**/*.tsx"
],
"exclude": [
"node_modules"
],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}