This commit is contained in:
2026-05-17 13:33:10 +02:00
parent b2cefb7d66
commit fed75d4820
54 changed files with 3845 additions and 51 deletions
Generated
+162
View File
@@ -2,6 +2,12 @@
# It is not intended for manual editing.
version = 4
[[package]]
name = "adler2"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "ahash"
version = "0.7.8"
@@ -128,6 +134,15 @@ version = "1.0.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
[[package]]
name = "arbitrary"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1"
dependencies = [
"derive_arbitrary",
]
[[package]]
name = "argon2"
version = "0.6.0-rc.8"
@@ -928,6 +943,15 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "217698eaf96b4a3f0bc4f3662aaa55bdf913cd54d7204591faa790070c6d0853"
[[package]]
name = "crc32fast"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
dependencies = [
"cfg-if",
]
[[package]]
name = "criterion"
version = "0.8.2"
@@ -1088,6 +1112,17 @@ dependencies = [
"serde_core",
]
[[package]]
name = "derive_arbitrary"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.117",
]
[[package]]
name = "derive_more"
version = "2.1.1"
@@ -1265,6 +1300,16 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
[[package]]
name = "flate2"
version = "1.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c"
dependencies = [
"miniz_oxide",
"zlib-rs",
]
[[package]]
name = "flume"
version = "0.11.1"
@@ -2121,6 +2166,26 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "mime_guess"
version = "2.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"
dependencies = [
"mime",
"unicase",
]
[[package]]
name = "miniz_oxide"
version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
dependencies = [
"adler2",
"simd-adler32",
]
[[package]]
name = "mio"
version = "1.2.0"
@@ -2313,6 +2378,7 @@ dependencies = [
"tracing",
"tracing-subscriber",
"utoipa",
"utoipa-swagger-ui",
"uuid",
"validator",
]
@@ -2888,6 +2954,40 @@ dependencies = [
"zeroize",
]
[[package]]
name = "rust-embed"
version = "8.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04113cb9355a377d83f06ef1f0a45b8ab8cd7d8b1288160717d66df5c7988d27"
dependencies = [
"rust-embed-impl",
"rust-embed-utils",
"walkdir",
]
[[package]]
name = "rust-embed-impl"
version = "8.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da0902e4c7c8e997159ab384e6d0fc91c221375f6894346ae107f47dd0f3ccaa"
dependencies = [
"proc-macro2",
"quote",
"rust-embed-utils",
"syn 2.0.117",
"walkdir",
]
[[package]]
name = "rust-embed-utils"
version = "8.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bcdef0be6fe7f6fa333b1073c949729274b05f123a0ad7efcb8efd878e5c3b1"
dependencies = [
"sha2",
"walkdir",
]
[[package]]
name = "rust-ini"
version = "0.21.3"
@@ -3292,6 +3392,12 @@ dependencies = [
"rand_core 0.6.4",
]
[[package]]
name = "simd-adler32"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214"
[[package]]
name = "simdutf8"
version = "0.1.5"
@@ -3964,6 +4070,12 @@ version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971"
[[package]]
name = "unicase"
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
[[package]]
name = "unicode-bidi"
version = "0.3.18"
@@ -4051,6 +4163,24 @@ dependencies = [
"uuid",
]
[[package]]
name = "utoipa-swagger-ui"
version = "9.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d047458f1b5b65237c2f6dc6db136945667f40a7668627b3490b9513a3d43a55"
dependencies = [
"axum",
"base64",
"mime_guess",
"regex",
"rust-embed",
"serde",
"serde_json",
"url",
"utoipa",
"zip",
]
[[package]]
name = "uuid"
version = "1.23.1"
@@ -4685,8 +4815,40 @@ dependencies = [
"syn 2.0.117",
]
[[package]]
name = "zip"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12598812502ed0105f607f941c386f43d441e00148fce9dec3ca5ffb0bde9308"
dependencies = [
"arbitrary",
"crc32fast",
"flate2",
"indexmap",
"memchr",
"zopfli",
]
[[package]]
name = "zlib-rs"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3be3d40e40a133f9c916ee3f9f4fa2d9d63435b5fbe1bfc6d9dae0aa0ada1513"
[[package]]
name = "zmij"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
[[package]]
name = "zopfli"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f05cd8797d63865425ff89b5c4a48804f35ba0ce8d125800027ad6017d2b5249"
dependencies = [
"bumpalo",
"crc32fast",
"log",
"simd-adler32",
]
+1
View File
@@ -26,6 +26,7 @@ tracing = "0.1.44"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt", "time"] }
thiserror = "2"
utoipa = { version = "5", features = ["uuid", "chrono"] }
utoipa-swagger-ui = { version = "9", features = ["axum"] }
log = "0.4"
bitflags = "2.11.1"
argon2 = { version = "0.6.0-rc.8", features = ["password-hash"] }
+1
View File
@@ -0,0 +1 @@
node_modules/
+4
View File
@@ -0,0 +1,4 @@
# Project Rules
## General
- Follow the existing code style and patterns.
+11
View File
@@ -0,0 +1,11 @@
# For a complete example, see: https://okigu.com/ruler#complete-example
# List of agents to configure
default_agents = ["copilot", "claude", "trae"]
[mcp_servers.vuetify]
url = "https://mcp.vuetifyjs.com/mcp"
# https://github.com/vuetifyjs/mcp#authentication
# [mcp_servers.vuetify.headers]
# Authorization = "Bearer <YOUR_API_KEY>"
+6
View File
@@ -0,0 +1,6 @@
{
"recommendations": [
"vuetifyjs.vuetify-vscode",
"vue.volar"
]
}
+11
View File
@@ -0,0 +1,11 @@
# Project Rules
## General
- Follow the existing code style and patterns.
- Use yarn for running project commands.
- Keep code in TypeScript unless migration is required.
## Stack
- Framework: Vue 3 + Vite
- UI Library: Vuetify
- Enabled Features: ESLint, Vuetify MCP, Pinia, Vue I18n, Vue Router
+83
View File
@@ -0,0 +1,83 @@
# oxspeak-frontend
Scaffolded with Vuetify CLI.
## ❗️ Documentation
- Primary docs: https://vuetifyjs.com/
- Getting started guide: https://vuetifyjs.com/en/getting-started/installation/
- Community support: https://community.vuetifyjs.com/
- Issue tracker: https://issues.vuetifyjs.com/
## 🧱 Stack
- Framework: Vue 3 + Vite
- UI Library: Vuetify
- Language: TypeScript
- Package manager: yarn
## 🧭 Start Here
- Main entry: `src/main.ts`
- Main app component: `src/App.vue`
- Main styles: `src/styles/`
- Plugin setup: `src/plugins/`
## 📁 Project Structure
- `src/main.ts` — application entry point
- `src/App.vue` — root component
- `src/components/` — reusable Vue components
- `src/plugins/` — plugin registration and setup
- `src/styles/` — global styles and theme settings
- `public/` — static public files
## ✨ Enabled Features
- ESLint
- Vuetify MCP
- Pinia
- Vue I18n
- Vue Router
## 💿 Install
Use your selected package manager (yarn) to install dependencies:
```bash
yarn install
```
## 🚀 Quick Start
```bash
yarn install
yarn dev
```
## 🏗️ Build
```bash
yarn build
```
## 🧪 Available Scripts
- `yarn dev`
- `yarn build`
- `yarn preview`
- `yarn build-only`
- `yarn type-check`
- `yarn lint`
- `yarn lint:fix`
- `yarn mcp`
- `yarn mcp:revert`
## 💪 Support Vuetify Development
This project uses Vuetify - an MIT licensed Open Source project. We are glad to welcome contributors and any support for ongoing development:
- Contribute to Vuetify and ecosystem projects: https://github.com/vuetifyjs
- Request enterprise support: https://support.vuetifyjs.com/
- Sponsor on GitHub: https://github.com/sponsors/vuetifyjs
- Support on Open Collective: https://opencollective.com/vuetify
+2
View File
@@ -0,0 +1,2 @@
/// <reference types="vite/client" />
/// <reference types="vite-plugin-vue-layouts-next/client" />
+5
View File
@@ -0,0 +1,5 @@
import vuetify from 'eslint-config-vuetify'
export default vuetify({
ts: true,
})
+13
View File
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to Vuetify 4</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
+47
View File
@@ -0,0 +1,47 @@
{
"name": "oxspeak-frontend",
"private": true,
"type": "module",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview",
"build-only": "vite build",
"type-check": "vue-tsc --build --force",
"lint": "eslint",
"lint:fix": "eslint --fix",
"mcp": "ruler apply",
"mcp:revert": "ruler revert"
},
"dependencies": {
"@fontsource/roboto": "^5.2.10",
"@mdi/font": "7.4.47",
"vue": "^3.5.30",
"vuetify": "^4.0.2",
"pinia": "^3.0.4",
"vue-i18n": "^11.3.0",
"vue-router": "^5.0.3"
},
"devDependencies": {
"@tsconfig/node22": "^22.0.5",
"@types/node": "^24.12.0",
"@vitejs/plugin-vue": "^6.0.5",
"@vue/tsconfig": "^0.9.0",
"npm-run-all2": "^8.0.4",
"sass-embedded": "^1.98.0",
"typescript": "~5.9.3",
"unplugin-fonts": "^1.4.0",
"vite": "^8.0.0",
"vite-plugin-vuetify": "^2.1.3",
"vue-tsc": "^3.2.5",
"eslint": "^9.39.4",
"eslint-config-vuetify": "^4.3.4",
"@intellectronica/ruler": "^0.3.37"
},
"overrides": {
"unplugin-fonts": {
"vite": "^8.0.0"
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

+11
View File
@@ -0,0 +1,11 @@
<template>
<v-app>
<v-main>
<router-view />
</v-main>
</v-app>
</template>
<script lang="ts" setup>
//
</script>
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

+6
View File
@@ -0,0 +1,6 @@
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M261.126 140.65L164.624 307.732L256.001 466L377.028 256.5L498.001 47H315.192L261.126 140.65Z" fill="#1697F6"/>
<path d="M135.027 256.5L141.365 267.518L231.64 111.178L268.731 47H256H14L135.027 256.5Z" fill="#AEDDFF"/>
<path d="M315.191 47C360.935 197.446 256 466 256 466L164.624 307.732L315.191 47Z" fill="#1867C0"/>
<path d="M268.731 47C76.0026 47 141.366 267.518 141.366 267.518L268.731 47Z" fill="#7BC6FF"/>
</svg>

After

Width:  |  Height:  |  Size: 526 B

+102
View File
@@ -0,0 +1,102 @@
<template>
<v-container class="fill-height d-flex flex-column justify-center" max-width="1100">
<div>
<v-img
class="mb-4 font-weight-bold"
height="150"
src="@/assets/logo.png"
/>
<div class="mb-8 text-center">
<div class="text-body-medium font-weight-light mb-n1">Welcome to</div>
<div class="text-display-medium font-weight-bold">Vuetify</div>
</div>
<v-row>
<v-col cols="12">
<v-card
class="py-4"
color="surface-variant"
image="https://cdn.vuetifyjs.com/docs/images/one/create/feature.png"
rounded="lg"
variant="tonal"
>
<template #prepend>
<v-avatar class="ml-2 mr-4" icon="mdi-rocket-launch-outline" size="60" variant="tonal"/>
</template>
<template #image>
<v-img position="top right"/>
</template>
<template #title>
<div class="my-title my-uppercase text-headline-medium font-weight-bold">Get started</div>
</template>
<template #subtitle>
<div class="text-body-large">
Change this page by updating
<v-kbd>{{
`
<HelloWorld/>
` }}
</v-kbd>
in
<v-kbd>components/HelloWorld.vue</v-kbd>
.
</div>
</template>
</v-card>
</v-col>
<v-col v-for="link in links" :key="link.href" cols="6">
<v-card
:href="link.href"
:subtitle="link.subtitle"
:title="link.title"
append-icon="mdi-open-in-new"
class="py-4"
color="surface-variant"
rel="noopener noreferrer"
rounded="lg"
target="_blank"
variant="tonal"
>
<template #prepend>
<v-avatar :icon="link.icon" class="ml-2 mr-4" size="60" variant="tonal"/>
</template>
</v-card>
</v-col>
</v-row>
</div>
</v-container>
</template>
<script lang="ts" setup>
const links = [
{
href: 'https://vuetifyjs.com/',
icon: 'mdi-text-box-outline',
subtitle: 'Learn about all things Vuetify in our documentation.',
title: 'Documentation',
},
{
href: 'https://vuetifyjs.com/introduction/why-vuetify/#feature-guides',
icon: 'mdi-star-circle-outline',
subtitle: 'Explore available framework Features.',
title: 'Features',
},
{
href: 'https://vuetifyjs.com/components/all',
icon: 'mdi-widgets-outline',
subtitle: 'Discover components in the API Explorer.',
title: 'Components',
},
{
href: 'https://discord.vuetifyjs.com',
icon: 'mdi-account-group-outline',
subtitle: 'Connect with Vuetify developers.',
title: 'Community',
},
]
</script>
+35
View File
@@ -0,0 +1,35 @@
# Components
Vue template files in this folder are automatically imported.
## 🚀 Usage
Importing is handled by [unplugin-vue-components](https://github.com/unplugin/unplugin-vue-components). This plugin automatically imports `.vue` files created in the `src/components` directory, and registers them as global components. This means that you can use any component in your application without having to manually import it.
The following example assumes a component located at `src/components/MyComponent.vue`:
```vue
<template>
<div>
<MyComponent />
</div>
</template>
<script lang="ts" setup>
//
</script>
```
When your template is rendered, the component's import will automatically be inlined, which renders to this:
```vue
<template>
<div>
<MyComponent />
</div>
</template>
<script lang="ts" setup>
import MyComponent from '@/components/MyComponent.vue'
</script>
```
+23
View File
@@ -0,0 +1,23 @@
/**
* main.ts
*
* Bootstraps Vuetify and other plugins then mounts the App`
*/
// Composables
import { createApp } from 'vue'
// Plugins
import { registerPlugins } from '@/plugins'
// Components
import App from './App.vue'
// Styles
import 'unfonts.css'
const app = createApp(App)
registerPlugins(app)
app.mount('#app')
+7
View File
@@ -0,0 +1,7 @@
<template>
<HelloWorld />
</template>
<script lang="ts" setup>
import HelloWorld from '@/components/HelloWorld.vue'
</script>
+3
View File
@@ -0,0 +1,3 @@
# Plugins
Plugins are a way to extend the functionality of your Vue application. Use this folder for registering plugins that you want to use globally.
+21
View File
@@ -0,0 +1,21 @@
import { createI18n } from 'vue-i18n'
const messages = {
en: {
message: {
hello: 'hello world',
},
},
ja: {
message: {
hello: 'こんにちは、世界',
},
},
}
export default createI18n({
legacy: false,
locale: 'en',
fallbackLocale: 'en',
messages,
})
+21
View File
@@ -0,0 +1,21 @@
import router from '../router';
import i18n from './i18n';
import {createPinia} from 'pinia';
/**
* plugins/index.ts
*
* Automatically included in `./src/main.ts`
*/
// Types
import type { App } from 'vue'
// Plugins
import vuetify from './vuetify'
export function registerPlugins (app: App) {
app.use(vuetify)
app.use(createPinia());
app.use(i18n);
app.use(router);
}
+19
View File
@@ -0,0 +1,19 @@
/**
* plugins/vuetify.ts
*
* Framework documentation: https://vuetifyjs.com`
*/
// Composables
import { createVuetify } from 'vuetify'
// Styles
import '@mdi/font/css/materialdesignicons.css'
import 'vuetify/styles'
// https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides
export default createVuetify({
theme: {
defaultTheme: 'system',
},
})
+21
View File
@@ -0,0 +1,21 @@
/**
* router/index.ts
*
* Manual routes for ./src/pages/*.vue
*/
// Composables
import { createRouter, createWebHistory } from 'vue-router'
import Index from '@/pages/index.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
component: Index,
},
],
})
export default router
+8
View File
@@ -0,0 +1,8 @@
// Utilities
import { defineStore } from 'pinia'
export const useAppStore = defineStore('app', {
state: () => ({
//
}),
})
+3
View File
@@ -0,0 +1,3 @@
# Styles
This directory is for configuring the styles of the application.
+10
View File
@@ -0,0 +1,10 @@
/**
* src/styles/settings.scss
*
* Configures SASS variables and Vuetify overwrites
*/
// https://vuetifyjs.com/features/sass-variables/`
// @use 'vuetify/settings' with (
// $color-pack: false
// );
+27
View File
@@ -0,0 +1,27 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": [
"env.d.ts",
"src/**/*",
"src/**/*.vue"
],
"exclude": [
"src/**/__tests__/*"
],
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
]
}
},
"vueCompilerOptions": {
"plugins": [
"vue-router/volar/sfc-typed-router",
"vue-router/volar/sfc-route-blocks"
]
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"files": [],
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.app.json"
}
]
}
+19
View File
@@ -0,0 +1,19 @@
{
"extends": "@tsconfig/node22/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*"
],
"compilerOptions": {
"composite": true,
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node"]
}
}
+50
View File
@@ -0,0 +1,50 @@
import { fileURLToPath, URL } from 'node:url'
import Vue from '@vitejs/plugin-vue'
import Fonts from 'unplugin-fonts/vite'
import { defineConfig } from 'vite'
import Vuetify, { transformAssetUrls } from 'vite-plugin-vuetify'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
Vue({
template: { transformAssetUrls },
}),
// https://github.com/vuetifyjs/vuetify-loader/tree/master/packages/vite-plugin#readme
Vuetify({
autoImport: true,
styles: {
configFile: 'src/styles/settings.scss',
},
}),
Fonts({
fontsource: {
families: [
{
name: 'Roboto',
weights: [100, 300, 400, 500, 700, 900],
styles: ['normal', 'italic'],
},
],
},
}),
],
define: { 'process.env': {} },
resolve: {
alias: {
'@': fileURLToPath(new URL('src', import.meta.url)),
},
extensions: [
'.js',
'.json',
'.jsx',
'.mjs',
'.ts',
'.tsx',
'.vue',
],
},
server: {
port: 3000,
},
})
+2844
View File
File diff suppressed because it is too large Load Diff
+6 -3
View File
@@ -1,12 +1,15 @@
use axum::{Router, routing::get};
use axum::{routing::get, Router};
use super::handlers;
pub fn router() -> Router {
Router::new()
.route("/attachments", get(handlers::get_all).post(handlers::create))
.route(
"/attachments/:id",
"/attachments",
get(handlers::get_all).post(handlers::create),
)
.route(
"/attachments/{id}",
get(handlers::get_by_id)
.put(handlers::update)
.delete(handlers::delete),
+9 -4
View File
@@ -8,11 +8,12 @@ use axum::Json;
#[utoipa::path(
post,
path = "/api/auth/login",
path = "/auth/login",
responses(
(status = 200, description = "Login successful", body = LoginResponse),
(status = 401, description = "Unauthorized")
)
),
tag = "Auth"
)]
pub async fn login_user_pw(
State(state): State<AppState>,
@@ -41,11 +42,15 @@ pub async fn login_user_pw(
#[utoipa::path(
post,
path = "/api/auth/check",
path = "/auth/check",
responses(
(status = 200, description = "Login successful", body = LoginResponse),
(status = 401, description = "Unauthorized")
)
),
security(
("bearerAuth" = [])
),
tag = "Auth"
)]
pub async fn check(
State(_state): State<AppState>,
+3 -9
View File
@@ -4,13 +4,7 @@ use axum::routing::post;
use axum::Router;
pub fn router() -> OxRouter {
Router::new().route("/login", post(handlers::login_user_pw))
// .route("/categorys", get(handlers::get_all).post(handlers::create))
// .route(
// "/categorys/:id",
// get(handlers::get_by_id)
// .put(handlers::update)
// .delete(handlers::delete),
// )
Router::new()
.route("/auth/login", post(handlers::login_user_pw))
.route("/auth/check", post(handlers::check))
}
+12 -3
View File
@@ -72,7 +72,10 @@ pub async fn get_by_id(
(status = 404, description = "Serveur non trouvé"),
(status = 500, description = "Erreur interne du serveur")
),
tag = "Categories"
tag = "Categories",
security(
("bearerAuth" = [])
)
)]
pub async fn create(
_admin: Superuser,
@@ -108,7 +111,10 @@ pub async fn create(
params(
("id" = Uuid, Path, description = "ID de la catégorie")
),
tag = "Categories"
tag = "Categories",
security(
("bearerAuth" = [])
)
)]
pub async fn update(
_admin: Superuser,
@@ -142,7 +148,10 @@ pub async fn update(
params(
("id" = Uuid, Path, description = "ID de la catégorie")
),
tag = "Categories"
tag = "Categories",
security(
("bearerAuth" = [])
)
)]
pub async fn delete(
_admin: Superuser,
+1 -1
View File
@@ -7,7 +7,7 @@ pub fn router() -> Router<AppState> {
Router::new()
.route("/categories", get(handlers::get_all).post(handlers::create))
.route(
"/categories/:id",
"/categories/{id}",
get(handlers::get_by_id)
.put(handlers::update)
.delete(handlers::delete),
+12 -3
View File
@@ -70,7 +70,10 @@ pub async fn get_by_id(
(status = 400, description = "Données invalides (Serveur ou Catégorie non trouvée)"),
(status = 500, description = "Erreur interne du serveur")
),
tag = "Channels"
tag = "Channels",
security(
("bearerAuth" = [])
)
)]
pub async fn create(
_admin: Superuser,
@@ -119,7 +122,10 @@ pub async fn create(
params(
("id" = Uuid, Path, description = "ID du channel")
),
tag = "Channels"
tag = "Channels",
security(
("bearerAuth" = [])
)
)]
pub async fn update(
_admin: Superuser,
@@ -173,7 +179,10 @@ pub async fn update(
params(
("id" = Uuid, Path, description = "ID du channel")
),
tag = "Channels"
tag = "Channels",
security(
("bearerAuth" = [])
)
)]
pub async fn delete(
_admin: Superuser,
+1 -1
View File
@@ -6,7 +6,7 @@ pub fn router() -> Router<AppState> {
Router::new()
.route("/channels", get(handlers::get_all).post(handlers::create))
.route(
"/channels/:id",
"/channels/{id}",
get(handlers::get_by_id)
.put(handlers::update)
.delete(handlers::delete),
+1 -1
View File
@@ -10,5 +10,5 @@ pub struct JoinRequest {
pub password: String,
#[validate(must_match(other = "password", message = "Passwords do not match"))]
pub password_valid: String,
pub super_admin_token: Option<String>,
pub superuser_token: Option<String>,
}
+13 -1
View File
@@ -7,6 +7,16 @@ use axum::extract::State;
use axum::http::StatusCode;
use axum::response::IntoResponse;
#[utoipa::path(
post,
path = "/join",
request_body = JoinRequest,
responses(
(status = 201, description = "User created successfully"),
(status = 400, description = "Validation error"),
),
tag = "Core"
)]
pub async fn join(
State(state): State<AppState>,
ValidatedJson(payload): ValidatedJson<JoinRequest>,
@@ -24,8 +34,10 @@ pub async fn join(
));
};
let user_am = join_request_to_user_am(payload)?;
let user_am = join_request_to_user_am(payload, state.init_token)?;
let user = state.repositories.user.create(user_am).await?;
state
.repositories
.server
+11 -1
View File
@@ -3,12 +3,22 @@ use crate::models::user;
use crate::routes::core::dto::JoinRequest;
use anyhow::Result as AnyResult;
use sea_orm::Set;
use uuid::Uuid;
pub fn join_request_to_user_am(
payload: JoinRequest,
superuser_token: Option<Uuid>,
) -> AnyResult<user::ActiveModel> {
let is_super_admin = match (payload.superuser_token.as_ref(), superuser_token) {
(Some(provided), Some(init)) => provided == &init.to_string(),
_ => false,
};
pub fn join_request_to_user_am(payload: JoinRequest) -> AnyResult<user::ActiveModel> {
Ok(user::ActiveModel {
id: Default::default(),
username: Set(payload.username),
password: Set(hash_password(&payload.password)?),
is_superuser: Set(is_super_admin),
..Default::default()
})
}
+2 -2
View File
@@ -1,7 +1,7 @@
use super::handlers;
use crate::http::OxRouter;
use axum::{routing::get, Router};
use axum::{routing::post, Router};
pub fn router() -> OxRouter {
Router::new().route("/join", get(handlers::join))
Router::new().route("/join", post(handlers::join))
}
+13 -4
View File
@@ -4,9 +4,9 @@ use crate::http::error::HTTPError;
use crate::routes::group::dto::{CreateGroupRequest, GroupResponse, UpdateGroupRequest};
use crate::routes::group::mapper;
use axum::{
Json,
extract::{Path, State},
http::StatusCode,
Json,
};
use uuid::Uuid;
@@ -68,7 +68,10 @@ pub async fn get_by_id(
(status = 404, description = "Serveur non trouvé"),
(status = 500, description = "Erreur interne du serveur")
),
tag = "Groups"
tag = "Groups",
security(
("bearerAuth" = [])
)
)]
pub async fn create(
_admin: Superuser,
@@ -104,7 +107,10 @@ pub async fn create(
params(
("id" = Uuid, Path, description = "ID du groupe")
),
tag = "Groups"
tag = "Groups",
security(
("bearerAuth" = [])
)
)]
pub async fn update(
_admin: Superuser,
@@ -138,7 +144,10 @@ pub async fn update(
params(
("id" = Uuid, Path, description = "ID du groupe")
),
tag = "Groups"
tag = "Groups",
security(
("bearerAuth" = [])
)
)]
pub async fn delete(
_admin: Superuser,
+1 -1
View File
@@ -7,7 +7,7 @@ pub fn router() -> Router<AppState> {
Router::new()
.route("/groups", get(handlers::get_all).post(handlers::create))
.route(
"/groups/:id",
"/groups/{id}",
get(handlers::get_by_id)
.put(handlers::update)
.delete(handlers::delete),
+12 -3
View File
@@ -70,7 +70,10 @@ pub async fn get_by_id(
(status = 400, description = "Données invalides (canal non trouvé)"),
(status = 500, description = "Erreur interne du serveur")
),
tag = "Messages"
tag = "Messages",
security(
("bearerAuth" = [])
)
)]
pub async fn create(
user: CurrentUser,
@@ -119,7 +122,10 @@ pub async fn create(
params(
("id" = Uuid, Path, description = "ID du message")
),
tag = "Messages"
tag = "Messages",
security(
("bearerAuth" = [])
)
)]
pub async fn update(
user: CurrentUser,
@@ -159,7 +165,10 @@ pub async fn update(
params(
("id" = Uuid, Path, description = "ID du message")
),
tag = "Messages"
tag = "Messages",
security(
("bearerAuth" = [])
)
)]
pub async fn delete(
user: CurrentUser,
+1 -1
View File
@@ -6,7 +6,7 @@ pub fn router() -> Router<AppState> {
Router::new()
.route("/messages", get(handlers::get_all).post(handlers::create))
.route(
"/messages/:id",
"/messages/{id}",
get(handlers::get_by_id)
.put(handlers::update)
.delete(handlers::delete),
+12 -3
View File
@@ -1,5 +1,7 @@
use crate::http::OxRouter;
use axum::Router;
use utoipa::OpenApi;
use utoipa_swagger_ui::SwaggerUi;
pub mod attachment;
pub mod auth;
@@ -8,17 +10,24 @@ pub mod channel;
pub mod core;
pub mod group;
pub mod message;
pub mod openapi;
pub mod server;
pub mod user;
pub fn router() -> OxRouter {
Router::new()
let api_routes = Router::new()
.merge(auth::routes::router())
.merge(server::routes::router())
.merge(category::routes::router())
.merge(channel::routes::router())
.merge(group::routes::router())
.merge(message::routes::router())
.merge(user::routes::router())
// .merge(attachment::routes::router())
.merge(user::routes::router());
Router::new()
.nest("/api", api_routes)
// .merge(attachment::routes::router())
.merge(
SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", openapi::ApiDoc::openapi()),
)
}
+114
View File
@@ -0,0 +1,114 @@
use crate::models::channel::ChannelType;
use crate::routes::*;
use utoipa::openapi::security::{HttpAuthScheme, HttpBuilder, SecurityScheme};
use utoipa::{Modify, OpenApi};
#[derive(OpenApi)]
#[openapi(
paths(
auth::handlers::login_user_pw,
auth::handlers::check,
user::handlers::get_all,
user::handlers::get_by_id,
user::handlers::create,
user::handlers::update,
user::handlers::delete,
server::handlers::get_all,
server::handlers::get_by_id,
server::handlers::create,
server::handlers::update,
server::handlers::delete,
category::handlers::get_all,
category::handlers::get_by_id,
category::handlers::create,
category::handlers::update,
category::handlers::delete,
channel::handlers::get_all,
channel::handlers::get_by_id,
channel::handlers::create,
channel::handlers::update,
channel::handlers::delete,
group::handlers::get_all,
group::handlers::get_by_id,
group::handlers::create,
group::handlers::update,
group::handlers::delete,
message::handlers::get_all,
message::handlers::get_by_id,
message::handlers::create,
message::handlers::update,
message::handlers::delete,
core::handlers::join,
),
components(
schemas(
auth::dto::LoginRequest,
auth::dto::LoginResponse,
auth::dto::CheckResponse,
user::dto::UserResponse,
user::dto::CreateUserRequest,
user::dto::UpdateUserRequest,
server::dto::ServerResponse,
server::dto::CreateServerRequest,
server::dto::UpdateServerRequest,
category::dto::CategoryResponse,
category::dto::CreateCategoryRequest,
category::dto::UpdateCategoryRequest,
channel::dto::ChannelResponse,
channel::dto::CreateChannelRequest,
channel::dto::UpdateChannelRequest,
group::dto::GroupResponse,
group::dto::CreateGroupRequest,
group::dto::UpdateGroupRequest,
message::dto::MessageResponse,
message::dto::CreateMessageRequest,
message::dto::UpdateMessageRequest,
core::dto::JoinRequest,
ChannelType,
)
),
modifiers(&SecurityAddon, &ApiPrefixAddon),
tags(
(name = "Auth", description = "Endpoints d'authentification"),
(name = "Users", description = "Gestion des utilisateurs"),
(name = "Servers", description = "Gestion des serveurs"),
(name = "Categories", description = "Gestion des catégories"),
(name = "Channels", description = "Gestion des salons"),
(name = "Groups", description = "Gestion des groupes"),
(name = "Messages", description = "Gestion des messages"),
(name = "Core", description = "Endpoints de base (enregistrement, etc.)"),
)
)]
pub struct ApiDoc;
struct SecurityAddon;
impl Modify for SecurityAddon {
fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
if let Some(components) = openapi.components.as_mut() {
components.add_security_scheme(
"bearerAuth",
SecurityScheme::Http(
HttpBuilder::new()
.scheme(HttpAuthScheme::Bearer)
.bearer_format("JWT")
.build(),
),
)
}
}
}
struct ApiPrefixAddon;
impl Modify for ApiPrefixAddon {
fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
let mut new_paths = utoipa::openapi::path::Paths::new();
for (path, item) in openapi.paths.paths.iter() {
new_paths
.paths
.insert(format!("/api{}", path), item.clone());
}
openapi.paths = new_paths;
}
}
+12 -3
View File
@@ -69,7 +69,10 @@ pub async fn get_by_id(
(status = 201, description = "Serveur créé avec succès", body = ServerResponse),
(status = 500, description = "Erreur interne du serveur")
),
tag = "Servers"
tag = "Servers",
security(
("bearerAuth" = [])
)
)]
pub async fn create(
_admin: Superuser,
@@ -97,7 +100,10 @@ pub async fn create(
params(
("id" = Uuid, Path, description = "ID du serveur")
),
tag = "Servers"
tag = "Servers",
security(
("bearerAuth" = [])
)
)]
pub async fn update(
_admin: Superuser,
@@ -131,7 +137,10 @@ pub async fn update(
params(
("id" = Uuid, Path, description = "ID du serveur")
),
tag = "Servers"
tag = "Servers",
security(
("bearerAuth" = [])
)
)]
pub async fn delete(
_admin: Superuser,
+1 -1
View File
@@ -6,7 +6,7 @@ pub fn router() -> Router<AppState> {
Router::new()
.route("/servers", get(handlers::get_all).post(handlers::create))
.route(
"/servers/:id",
"/servers/{id}",
get(handlers::get_by_id)
.put(handlers::update)
.delete(handlers::delete),
+20 -5
View File
@@ -20,7 +20,10 @@ use uuid::Uuid;
(status = 403, description = "Interdit"),
(status = 500, description = "Erreur interne du serveur")
),
tag = "Users"
tag = "Users",
security(
("bearerAuth" = [])
)
)]
pub async fn get_all(
_admin: Superuser,
@@ -49,7 +52,10 @@ pub async fn get_all(
params(
("id" = Uuid, Path, description = "ID de l'utilisateur")
),
tag = "Users"
tag = "Users",
security(
("bearerAuth" = [])
)
)]
pub async fn get_by_id(
_admin: Superuser,
@@ -78,7 +84,10 @@ pub async fn get_by_id(
(status = 403, description = "Interdit"),
(status = 500, description = "Erreur interne du serveur")
),
tag = "Users"
tag = "Users",
security(
("bearerAuth" = [])
)
)]
pub async fn create(
_admin: Superuser,
@@ -120,7 +129,10 @@ pub async fn create(
params(
("id" = Uuid, Path, description = "ID de l'utilisateur")
),
tag = "Users"
tag = "Users",
security(
("bearerAuth" = [])
)
)]
pub async fn update(
_admin: Superuser,
@@ -167,7 +179,10 @@ pub async fn update(
params(
("id" = Uuid, Path, description = "ID de l'utilisateur")
),
tag = "Users"
tag = "Users",
security(
("bearerAuth" = [])
)
)]
pub async fn delete(
_admin: Superuser,
+1 -1
View File
@@ -7,7 +7,7 @@ pub fn router() -> Router<AppState> {
Router::new()
.route("/users", get(handlers::get_all).post(handlers::create))
.route(
"/users/:id",
"/users/{id}",
get(handlers::get_by_id)
.put(handlers::update)
.delete(handlers::delete),