refactor: change backend to typescript and update types and variables accordingly

This commit is contained in:
2026-07-08 10:54:07 +02:00
parent 36ec8da1a0
commit 84fa2e0ab0
24 changed files with 1911 additions and 615 deletions
+17
View File
@@ -0,0 +1,17 @@
{
"name": "@stockhome/shared",
"private": true,
"version": "1.0.0",
"type": "module",
"scripts": {
"prebuild": "barrelsby --directory src --delete --single",
"build": "tsc",
"lint": "eslint ."
},
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"devDependencies": {
"barrelsby": "^2.8.1",
"vite-plugin-dts": "^5.0.3"
}
}
+35 -4
View File
@@ -1,4 +1,35 @@
export enum ERROR_CODE {
WRONG_USER_NAME_PASSWORD = 'EU001',
UNEXPECTED_FORMAT = 'ES001',
}
export const GENERAL_ERROR_CODE = {
UNEXPECTED_SERVER_ERROR: ["EG001", "Unexpected server error"],
} as const;
export const USER_ERROR_CODE = {
WRONG_USERNAME_PASSWORD: ["EU001", "Username or password is wrong"],
USER_IS_DEACTIVATED: ["EU002", "User is deactivated"],
INVALID_REQUEST_BODY: ["EU003", "Invalid request body. Username and password are required."],
INVALID_PARAMETERS: ["EU004", "Invalid or missing parameters."],
TOKEN_GENERATION_FAILED: ["EU005", "Failed to generate user token."],
LOGIN_FAILED: ["EU006", "Failed to log in user."],
PASSWORD_CHANGE_FAILED: ["EU007", "Failed to change password."],
SETTINGS_NOT_UPDATED: ["EU008", "Settings could not be updated."],
SETTINGS_NOT_FOUND: ["EU009", "Settings could not be retrieved."],
} as const;
export const STORAGE_ERROR_CODE = {
INVALID_REQUEST_BODY: ["ES001", "Invalid request body"],
INVALID_PARAMETERS: ["ES002", "Parameter storageUUID or/and parameter values are/is missing."],
STORAGE_NOT_UPDATED: ["ES003", "Storage is not updated."],
STORAGE_NOT_DELETED: ["ES004", "Storage is not deleted."],
NO_STORAGE_LOCATIONS_FOUND: ["ES005", "No storage locations found"],
STORAGE_NOT_CREATED: ["ES006", "Storage is not created."],
} as const;
export const PRODUCT_ERROR_CODE = {
PRODUCT_NOT_CREATED: ["EP001", "Error while creating product"],
NO_PRODUCTS_FOUND: ["EP002", "No products found"],
PRODUCT_NOT_FOUND: ["EP003", "Product not found"],
PRODUCT_AMOUNT_NOT_UPDATED: ["EP004", "Error while updating product amount"],
PRODUCT_NOT_UPDATED: ["EP005", "Error while updating product"],
PRODUCT_NOT_DELETED: ["EP006", "Error while deleting product"],
INVALID_REQUEST_BODY: ["EP007", "Invalid request body. Name is required."],
INVALID_PARAMETERS: ["EP008", "Invalid or missing parameters."],
} as const;
+2
View File
@@ -9,6 +9,8 @@
// See also https://aka.ms/tsconfig/module
"module": "esnext",
"target": "esnext",
"esModuleInterop": true,
"moduleResolution": "node",
"types": [],
// For nodejs:
// "lib": ["esnext"],
+2 -8
View File
@@ -1,15 +1,9 @@
import { defineConfig } from "vite";
import react, { reactCompilerPreset } from "@vitejs/plugin-react";
import babel from "@rolldown/plugin-babel";
import tailwindcss from "@tailwindcss/vite";
import { TanStackRouterVite } from "@tanstack/router-vite-plugin";
import dts from "vite-plugin-dts";
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
tailwindcss(),
TanStackRouterVite(),
babel({ presets: [reactCompilerPreset()] }),
dts(),
],
});