Initial commit: NestJS NextJS pnpm monorepo

This commit is contained in:
Marco_205 committed 2026-10-12 07:20:37 +00:00
commit 610dcf202b
175 files changed
+25172

No files matched your search

+94
View File
@@ -0,0 +1,94 @@
'use server'
import { revalidatePath } from 'next/cache'
import { Article, ArticleCreate, ArticleUpsert } from "@/apps/frontend/types/catalog";
import { sites } from '../_config/sites';
export async function articleCreate(data: ArticleCreate) {
console.log(data);
const result = await fetch('http://192.168.50.205/api/articles', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
})
const resultData = await result.json();
if (!result.ok) {
return {
success: false,
errors: resultData.message, // kommt aus NestJS
};
}
revalidatePath(sites.article.new.url)
}
export async function articleUpdate(id: string, data: ArticleUpsert): Promise<ActionResult> {
const result = await fetch(`http://192.168.50.205/api/articles/${id}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
})
const resultData = await result.json();
if (!result.ok) {
return {
success: false,
errors: resultData.message, // kommt aus NestJS
};
}
revalidatePath(sites.article.update.url + '/' + id);
return { success: true };
}
export async function articleFindAll(): Promise<Article[]> {
const result = await fetch(`http://192.168.50.205/api/articles`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
})
const data = await result.json() as Article[];
return data;
}
export async function articleFindById(id: string): Promise<any> {
const result = await fetch(`http://192.168.50.205/api/articles/${id}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
})
const data = await result.json() as Article
console.log('getArticle', data)
return data;
}
export async function articleDelete(id: string,revalidateUrl?:string): Promise<ActionResult> {
const result = await fetch(`http://192.168.50.205/api/articles/${id}`, {
method: 'DELETE',
headers: { 'Content-Type': 'application/json' }
})
const resultData = await result.json();
if (!result.ok) {
return {
success: false,
errors: resultData.message, // kommt aus NestJS
};
}
if(revalidateUrl) revalidatePath(revalidateUrl);
return { success: true };
}
+49
View File
@@ -0,0 +1,49 @@
'use server'
import { revalidatePath } from 'next/cache'
import { Category, CategoryCreate } from "@/apps/frontend/types/catalog";
export async function categoryCreate(data: CategoryCreate) {
console.log(data);
const result = await fetch('http://192.168.50.205/api/categories', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
})
console.log(result);
revalidatePath('/test')
}
export async function categoryUpdate( id: string, data: Partial<CategoryCreate>) {
console.log(data,id);
const result = await fetch(`http://192.168.50.205/api/categories/${id}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
})
console.log(result);
revalidatePath('/test')
}
export async function categoryFindAll():Promise<Category[]> {
const result = await fetch(`http://192.168.50.205/api/categories`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
})
const data = await result.json();
return data;
}
export async function categoryFindById(id:string):Promise<Category> {
const result = await fetch(`http://192.168.50.205/api/categories/${id}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
})
const data = await result.json();
return data;
}
+69
View File
@@ -0,0 +1,69 @@
'use server'
import { Location, LocationCreate, LocationTreeNode, LocationUpdate } from "../types/inventory";
import { endpoints } from '../_config/endpoints';
import { revalidateTag, revalidatePath } from "next/cache"
export async function locationCreate(data: LocationCreate) {
console.log(`${endpoints.apiServer}${endpoints.location}`);
const result = await fetch(`${endpoints.apiServer.url}${endpoints.location.url}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
})
const respData = await result.json();
revalidateTag("location", "default");
return respData;
console.log(data)
}
export async function locationUpdate(id: string, data: LocationUpdate) {
const result = await fetch(`${endpoints.apiServer.url}${endpoints.location.url}/${id}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
})
const respData = await result.json();
revalidateTag("location", "default");
return respData;
}
export async function locationFindAll(): Promise<Location[]> {
const result = await fetch(`${endpoints.apiServer.url}${endpoints.location.url}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
})
const data = await result.json();
return data;
}
export async function locationTree(): Promise<LocationTreeNode[]> {
const result = await fetch(`${endpoints.apiServer.url}${endpoints.location.treeView.url}`, {
next: { tags: ["location"] },
method: 'GET',
headers: { 'Content-Type': 'application/json' }
})
const data = await result.json();
return data;
}
export async function locationFindById(id: string): Promise<Location> {
const result = await fetch(`${endpoints.apiServer.url}${endpoints.location.url}/${id}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
})
const respData = await result.json();
return respData;
}
@@ -0,0 +1,74 @@
'use server'
import { revalidatePath } from 'next/cache'
import { Manufacturer, ManufacturerCreate } from "@/apps/frontend/types/catalog";
import { sites } from '../_config/sites';
export async function manufacturerCreate(data: ManufacturerCreate): Promise<ActionResult> {
const result = await fetch('http://192.168.50.205/api/manufacturer', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
})
const resultData = await result.json();
if (!result.ok) {
return {
success: false,
errors: resultData.message,
};
}
// revalidatePath(sites.manufacturer.new.url);
return { success: true, data:resultData };
}
export async function manufacturerUpdate(id: string, data: Partial<ManufacturerCreate>): Promise<ActionResult> {
console.log(data, id);
const result = await fetch(`http://192.168.50.205/api/manufacturer/${id}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
})
const resultData = await result.json();
if (!result.ok) {
return {
success: false,
errors: resultData.message,
};
}
revalidatePath(sites.manufacturer.update.url + '/' + id);
revalidatePath(sites.manufacturer.url );
return { success: true, data:resultData.data };
}
export async function manufacturerFindAll(): Promise<Manufacturer[]> {
const result = await fetch(`http://192.168.50.205/api/manufacturer`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
})
const data = await result.json();
return data;
}
export async function manufacturerFindById(id: string): Promise<Manufacturer> {
const result = await fetch(`http://192.168.50.205/api/manufacturer/${id}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
})
const data = await result.json();
return data;
}
+94
View File
@@ -0,0 +1,94 @@
'use server'
import { revalidatePath } from 'next/cache'
import { sites } from '../_config/sites';
import { Stock, StockCreate, StockUpdate } from '../types/inventory/stockContent.types';
export async function stockCreate(data: StockCreate) {
const result = await fetch('http://192.168.50.205/api/stock', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
})
const resultData = await result.json();
if (!result.ok) {
return {
success: false,
errors: resultData.message, // kommt aus NestJS
};
}
revalidatePath(sites.stock.new.url)
}
export async function stockUpdate(id: string, data: StockUpdate): Promise<ActionResult> {
const result = await fetch(`http://192.168.50.205/api/stocks/${id}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
})
const resultData = await result.json();
if (!result.ok) {
return {
success: false,
errors: resultData.message, // kommt aus NestJS
};
}
revalidatePath(sites.stock.update.url + '/' + id);
return { success: true };
}
export async function stockFindAll(): Promise<Stock[]> {
const result = await fetch(`http://192.168.50.205/api/stocks`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
})
const data = await result.json() as Stock[];
return data;
}
export async function stockFindById(id: string): Promise<any> {
const result = await fetch(`http://192.168.50.205/api/stocks/${id}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
})
const data = await result.json() as Stock
console.log('getArticle', data)
return data;
}
export async function stockDelete(id: string,revalidateUrl?:string): Promise<ActionResult> {
const result = await fetch(`http://192.168.50.205/api/stocks/${id}`, {
method: 'DELETE',
headers: { 'Content-Type': 'application/json' }
})
const resultData = await result.json();
if (!result.ok) {
return {
success: false,
errors: resultData.message, // kommt aus NestJS
};
}
if(revalidateUrl) revalidatePath(revalidateUrl);
return { success: true };
}