1# Jobrapido Backend
23This is the Django backend for the Jobrapido application. It provides API endpoints for user authentication, profile management, and other features.
45## Project Structure
67- `api/` - Main Django app containing models, views, and API endpoints
8- `jobrapido/` - Django project settings
9- `templates/` - Django templates for non-admin users
1037```
3839## API Endpoints
4041- `/api/register/` - User registration
42- `/api/login/` - User login
43- `/api/send-verification-code/` - Send email verification code
44- `/api/profile/` - Get or update user profile
45- `/api/forgot-password/` - Request password reset
react-router-hono-starterserver.tsx2 matches
14const app = new Hono();
1516// api server
17app.get("/api", async (c) => {
18return c.json([
19{ name: "Leia", breed: "DSH", coat: "Calico" },
90}
9192// API response types
93export interface ApiResponse<T> {
94success: boolean;
95data?: T;
39```
40โโโ backend/
41โ โโโ index.ts # Main API entry point
42โ โโโ auth/ # Authentication functions
43โ โโโ database/ # Database operations
44โ โโโ routes/ # API routes
45โ โโโ utils/ # Utility functions
46โโโ frontend/
18await initializeDatabase();
1920// API routes
21app.get("/api/messages", async (c) => {
22const messages = await getMessages();
23return c.json(messages);
24});
2526app.post("/api/messages", async (c) => {
27const { username, content } = await c.req.json();
28
57const fetchMessages = async () => {
58try {
59const response = await fetch('/api/messages');
60if (!response.ok) {
61throw new Error('Failed to fetch messages');
94
95try {
96const response = await fetch('/api/messages', {
97method: 'POST',
98headers: {
26});
2728// API routes
29const api = new Hono();
3031// Create a new game room
32api.post("/room/create", async c => {
33const body = await c.req.json();
34const { playerId } = body;
4849// Join a game room
50api.post("/room/join", async c => {
51const body = await c.req.json();
52const { roomId, playerId } = body;
7071// Start a game
72api.post("/game/start", async c => {
73const body = await c.req.json();
74const { roomId, playerId } = body;
9192// Get game state
93api.get("/game/state", async c => {
94const roomId = c.req.query("roomId");
95const playerId = c.req.query("playerId");
116117// Play a card
118api.post("/game/play", async c => {
119const body = await c.req.json();
120const { roomId, playerId, cardId, chosenColor } = body;
146147// Draw a card
148api.post("/game/draw", async c => {
149const body = await c.req.json();
150const { roomId, playerId } = body;
176177// Call UNO
178api.post("/game/uno", async c => {
179const body = await c.req.json();
180const { roomId, playerId } = body;
206207// Challenge UNO
208api.post("/game/challenge", async c => {
209const body = await c.req.json();
210const { roomId, playerId, targetPlayerId } = body;
236237// List all rooms
238api.get("/rooms", async c => {
239const rooms = await listRooms();
240
251});
252253// Mount the API routes
254app.route("/api", api);
255256// Export the app
2import React, { useState, useEffect } from "https://esm.sh/react@18.2.0";
3import { Card as CardType, CardColor, GameState } from "../../shared/types";
4import { API_ENDPOINTS } from "../../shared/constants";
5import PlayerHand from "./PlayerHand";
6import GameBoard from "./GameBoard";
48const fetchGameState = async () => {
49try {
50const response = await fetch(`${API_ENDPOINTS.GAME_STATE}?roomId=${roomId}&playerId=${playerId}`);
51const data = await response.json();
52
72
73try {
74const response = await fetch(API_ENDPOINTS.CREATE_ROOM, {
75method: "POST",
76headers: {
112
113try {
114const response = await fetch(API_ENDPOINTS.JOIN_ROOM, {
115method: "POST",
116headers: {
141
142try {
143const response = await fetch(API_ENDPOINTS.START_GAME, {
144method: "POST",
145headers: {
184
185try {
186const response = await fetch(API_ENDPOINTS.PLAY_CARD, {
187method: "POST",
188headers: {
220
221try {
222const response = await fetch(API_ENDPOINTS.DRAW_CARD, {
223method: "POST",
224headers: {
248
249try {
250const response = await fetch(API_ENDPOINTS.CALL_UNO, {
251method: "POST",
252headers: {
cardamumconstants.ts10 matches
26};
2728// API endpoints
29export const API_ENDPOINTS = {
30CREATE_ROOM: "/api/room/create",
31JOIN_ROOM: "/api/room/join",
32START_GAME: "/api/game/start",
33GAME_STATE: "/api/game/state",
34PLAY_CARD: "/api/game/play",
35DRAW_CARD: "/api/game/draw",
36CALL_UNO: "/api/game/uno",
37CHALLENGE_UNO: "/api/game/challenge"
38};