Ajout des fichiers de base pour le projet.

This commit is contained in:
2025-08-12 17:18:10 +00:00
parent 0695d2ca1e
commit 14e69e1f61
20 changed files with 2087 additions and 0 deletions

View File

@ -0,0 +1,54 @@
import { Hono } from "hono";
import { AccountServiceInterface } from "../service/AccountServiceInterface";
export default function toRoutes(
accountService: AccountServiceInterface,
): Hono {
const app = new Hono();
app.post("/login", async (ctx) => {
try {
const { email, password } = await ctx.req.json();
const account = await accountService.login(email, password);
return ctx.json({
success: true,
accountId: account.id,
email: account.email,
});
} catch (error) {
return ctx.json(
{
success: false,
error: error instanceof Error ? error.message : "Erreur inconnue",
},
400,
);
}
});
app.post("/register", async (ctx) => {
try {
const { email, password } = await ctx.req.json();
const account = await accountService.createAccount(email, password);
return ctx.json({
success: true,
accountId: account.id,
email: account.email,
});
} catch (error) {
return ctx.json(
{
success: false,
error: error instanceof Error ? error.message : "Erreur inconnue",
},
400,
);
}
});
return app;
}