Update frontend/CLAUDE.md

This commit is contained in:
2026-10-03 12:01:47 +00:00
parent f157c08ec1
commit f49d9fb807
+37 -19
View File
@@ -1,23 +1,41 @@
# Code Style
- You never use comments
- We use `npm i @stdlib/string-format` for formatting strings. Always. Install if not yet done.
- We always use NUXT's useFetch
- We always use feature first packaging. Every class that is part of a entity is in its own folder
- We always define types like this (image/Image.ts):
```typescript
export interface Image {
id: string;
name: string;
tags?: Tag[];
# Setup
- We always use Nuxt together with Tailwind. Install tailwind like that: https://tailwindcss.com/docs/installation/framework-guides/nuxt
# Components
- Ausnahmslos template -> script -> style von oben nach unten
- Immer `<script setup lang="ts"></script> und <style scoped></style>`
# General Code Best Practices:
- Keine ternären Operatoren, Immer switch oder if
- Null-Checks so früh wie möglich. Vermeiden von ! oder ?
- Nutz shared/useHttp für Requests.
- Nutz `import format from "@stdlib/string-format";`
# Types und API Calls
- Types und Api Calls werden wie folgt unterteilt. Immer ein Type und ein API Objekt wie
```javascript
export interface Project {
name: string
}
```
- And a types API like this (image/ImageAPI.ts):
```typescript
export class ImageAPI {
static getAll() {
return useFetch<Image[]>('/api/images/', { server: false });
export class ProjectAPI {
static get() {
return usePost<Project>("/api/projects");
}
}
```
- We put sections/components that are part of a pages into its own dedicated folder inside ./components
- Always identify snippets of code that can be extracted
- Verwendung im Komponente:
```javascript
<script setup lang="ts">
const {...} state = ProjectAPI.get();
onMounted(() => {
state.execute();
})
</script>
```
# Pages und Components
- Seiten beinhalten minimal Inhalt. Der Hauptteil des Inhalts ist in components.
Dort werden auch Types/Klassen/Interfaces/Requests angelegt.
Wir arbeiten feature-first, also packen alle inhaltlich zusammengehörigen Code in einen Bereich also components/projects oder components/images