35runMigrations().catch(console.error);
3637// Montar rotas da API
38app.route("/api/auth", authRoutes);
39app.route("/api/projects", projectRoutes);
40app.route("/api/tasks", taskRoutes);
4142// Adicionar rotas de autenticação do lastlogin
10deleteTask
11} from "../database/queries.ts";
12import { formatApiResponse } from "../../shared/utils.ts";
13import { CreateTaskInput, UpdateTaskInput } from "../../shared/types.ts";
1428if (!body.title) {
29return c.json(
30formatApiResponse(false, undefined, "TÃtulo da tarefa é obrigatório"),
31400
32);
35if (!body.projectId) {
36return c.json(
37formatApiResponse(false, undefined, "ID do projeto é obrigatório"),
38400
39);
47});
48
49return c.json(formatApiResponse(true, task));
50} catch (error) {
51console.error("Erro ao criar tarefa:", error);
52return c.json(
53formatApiResponse(false, undefined, "Erro ao criar tarefa"),
54500
55);
66const tasks = await getTasksByUserId(1); // Temporary fix
67
68return c.json(formatApiResponse(true, tasks));
69} catch (error) {
70console.error("Erro ao buscar tarefas:", error);
71return c.json(
72formatApiResponse(false, undefined, "Erro ao buscar tarefas"),
73500
74);
84if (isNaN(projectId)) {
85return c.json(
86formatApiResponse(false, undefined, "ID de projeto inválido"),
87400
88);
93const tasks = await getTasksByProjectId(projectId, 1); // Temporary fix
94
95return c.json(formatApiResponse(true, tasks));
96} catch (error) {
97console.error("Erro ao buscar tarefas do projeto:", error);
98return c.json(
99formatApiResponse(false, undefined, "Erro ao buscar tarefas do projeto"),
100500
101);
111if (isNaN(id)) {
112return c.json(
113formatApiResponse(false, undefined, "ID de tarefa inválido"),
114400
115);
122if (!task) {
123return c.json(
124formatApiResponse(false, undefined, "Tarefa não encontrada"),
125404
126);
127}
128
129return c.json(formatApiResponse(true, task));
130} catch (error) {
131console.error("Erro ao buscar tarefa:", error);
132return c.json(
133formatApiResponse(false, undefined, "Erro ao buscar tarefa"),
134500
135);
146if (isNaN(id)) {
147return c.json(
148formatApiResponse(false, undefined, "ID de tarefa inválido"),
149400
150);
157if (!existingTask) {
158return c.json(
159formatApiResponse(false, undefined, "Tarefa não encontrada"),
160404
161);
166const updatedTask = await updateTask(id, 1, body); // Temporary fix
167
168return c.json(formatApiResponse(true, updatedTask));
169} catch (error) {
170console.error("Erro ao atualizar tarefa:", error);
171return c.json(
172formatApiResponse(false, undefined, "Erro ao atualizar tarefa"),
173500
174);
184if (isNaN(id)) {
185return c.json(
186formatApiResponse(false, undefined, "ID de tarefa inválido"),
187400
188);
195if (!existingTask) {
196return c.json(
197formatApiResponse(false, undefined, "Tarefa não encontrada"),
198404
199);
204const updatedTask = await toggleTaskCompletion(id, 1); // Temporary fix
205
206return c.json(formatApiResponse(true, updatedTask));
207} catch (error) {
208console.error("Erro ao alternar status de tarefa:", error);
209return c.json(
210formatApiResponse(false, undefined, "Erro ao alternar status de tarefa"),
211500
212);
222if (isNaN(id)) {
223return c.json(
224formatApiResponse(false, undefined, "ID de tarefa inválido"),
225400
226);
233if (!existingTask) {
234return c.json(
235formatApiResponse(false, undefined, "Tarefa não encontrada"),
236404
237);
244if (!deleted) {
245return c.json(
246formatApiResponse(false, undefined, "Erro ao excluir tarefa"),
247500
248);
250
251return c.json(
252formatApiResponse(true, { message: "Tarefa excluÃda com sucesso" })
253);
254} catch (error) {
255console.error("Erro ao excluir tarefa:", error);
256return c.json(
257formatApiResponse(false, undefined, "Erro ao excluir tarefa"),
258500
259);
TastkItprojects.ts19 matches
8deleteProject
9} from "../database/queries.ts";
10import { formatApiResponse } from "../../shared/utils.ts";
11import { CreateProjectInput, UpdateProjectInput } from "../../shared/types.ts";
1226if (!body.name) {
27return c.json(
28formatApiResponse(false, undefined, "Nome do projeto é obrigatório"),
29400
30);
38});
39
40return c.json(formatApiResponse(true, project));
41} catch (error) {
42console.error("Erro ao criar projeto:", error);
43return c.json(
44formatApiResponse(false, undefined, "Erro ao criar projeto"),
45500
46);
57const projects = await getProjectsByUserId(1); // Temporary fix
58
59return c.json(formatApiResponse(true, projects));
60} catch (error) {
61console.error("Erro ao buscar projetos:", error);
62return c.json(
63formatApiResponse(false, undefined, "Erro ao buscar projetos"),
64500
65);
75if (isNaN(id)) {
76return c.json(
77formatApiResponse(false, undefined, "ID de projeto inválido"),
78400
79);
86if (!project) {
87return c.json(
88formatApiResponse(false, undefined, "Projeto não encontrado"),
89404
90);
91}
92
93return c.json(formatApiResponse(true, project));
94} catch (error) {
95console.error("Erro ao buscar projeto:", error);
96return c.json(
97formatApiResponse(false, undefined, "Erro ao buscar projeto"),
98500
99);
110if (isNaN(id)) {
111return c.json(
112formatApiResponse(false, undefined, "ID de projeto inválido"),
113400
114);
121if (!existingProject) {
122return c.json(
123formatApiResponse(false, undefined, "Projeto não encontrado"),
124404
125);
135);
136
137return c.json(formatApiResponse(true, updatedProject));
138} catch (error) {
139console.error("Erro ao atualizar projeto:", error);
140return c.json(
141formatApiResponse(false, undefined, "Erro ao atualizar projeto"),
142500
143);
153if (isNaN(id)) {
154return c.json(
155formatApiResponse(false, undefined, "ID de projeto inválido"),
156400
157);
164if (!existingProject) {
165return c.json(
166formatApiResponse(false, undefined, "Projeto não encontrado"),
167404
168);
175if (!deleted) {
176return c.json(
177formatApiResponse(false, undefined, "Erro ao excluir projeto"),
178500
179);
181
182return c.json(
183formatApiResponse(true, { message: "Projeto excluÃdo com sucesso" })
184);
185} catch (error) {
186console.error("Erro ao excluir projeto:", error);
187return c.json(
188formatApiResponse(false, undefined, "Erro ao excluir projeto"),
189500
190);
13const checkAuth = async () => {
14try {
15const response = await fetch("/api/auth/me", {
16method: "GET",
17credentials: "include",
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { formatApiResponse } from "../../shared/utils.ts";
34// Create auth router
12if (!email) {
13return c.json(
14formatApiResponse(false, undefined, "Não autorizado"),
15401
16);
24console.error("Erro de autenticação:", error);
25return c.json(
26formatApiResponse(false, undefined, "Não autorizado"),
27401
28);
36
37return c.json(
38formatApiResponse(true, {
39user: {
40email: email,
45console.error("Erro ao verificar autenticação:", error);
46return c.json(
47formatApiResponse(false, undefined, "Erro ao verificar autenticação"),
48500
49);
project1Profile.tsx7 matches
35try {
36// Fetch user profile
37const profileResponse = await fetch("/api/users/profile", {
38headers: {
39"Authorization": `Bearer ${token}`
51
52// Fetch user skills
53const skillsResponse = await fetch("/api/users/skills", {
54headers: {
55"Authorization": `Bearer ${token}`
64
65// Fetch available skills
66const availableSkillsResponse = await fetch("/api/users/skills/available", {
67headers: {
68"Authorization": `Bearer ${token}`
93
94try {
95const response = await fetch("/api/users/profile", {
96method: "PUT",
97headers: {
145
146try {
147const response = await fetch("/api/users/skills", {
148method: "POST",
149headers: {
165
166// Refresh user skills
167const skillsResponse = await fetch("/api/users/skills", {
168headers: {
169"Authorization": `Bearer ${token}`
190const handleRemoveSkill = async (skillId: number) => {
191try {
192const response = await fetch(`/api/users/skills/${skillId}`, {
193method: "DELETE",
194headers: {
project1JobDetail.tsx3 matches
22const fetchJobDetails = async () => {
23try {
24const response = await fetch(`/api/jobs/${id}`);
25const data = await response.json();
26
34// Check if user has already applied
35if (isAuthenticated && token) {
36const applicationsResponse = await fetch("/api/applications/my", {
37headers: {
38"Authorization": `Bearer ${token}`
73
74try {
75const response = await fetch("/api/applications", {
76method: "POST",
77headers: {
project1JobList.tsx3 matches
21try {
22// Fetch all jobs
23const response = await fetch("/api/jobs");
24const data = await response.json();
25
34// Fetch matching jobs if authenticated
35if (isAuthenticated && token) {
36const matchingResponse = await fetch("/api/jobs/matching", {
37headers: {
38"Authorization": `Bearer ${token}`
48
49// Fetch available skills
50const skillsResponse = await fetch("/api/users/skills/available", {
51headers: isAuthenticated ? {
52"Authorization": `Bearer ${token}`
project1Register.tsx1 match
41
42try {
43const response = await fetch("/api/auth/register", {
44method: "POST",
45headers: {