Skip to content

Commit

Permalink
[frontend] feat: Updating api routing
Browse files Browse the repository at this point in the history
  • Loading branch information
helloitsdave committed Mar 23, 2024
1 parent d2f69b3 commit 721878a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
13 changes: 10 additions & 3 deletions backend/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,22 @@ export const seed = [

async function main() {
// Seed user data
await prisma.user.create({
data: {
await prisma.user.createMany({
data: [{
id : 'ccf89a7e-b941-4f17-bbe0-4e0c8b2cd272',
email: '[email protected]',
password: 'n0te$App!23',
username: 'Test User',
createdAt: "2024-02-05T23:33:42.260Z",
updatedAt: "2024-02-05T23:33:42.260Z",
}
}, {
id : 'dcf89a7e-b941-4f17-bbe0-4e0c8b2cd272',
email: '[email protected]',
password: 'test',
username: 'dave',
createdAt: "2024-02-05T23:34:42.260Z",
updatedAt: "2024-02-05T23:34:42.260Z",
}]
});

// Seed note data
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/api/apiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import axios from "axios";
import type NoteType from "../types/note";

const URL =
process.env.REACT_APP_API_BASE_URL || "http://localhost:5000/api/notes";
process.env.REACT_APP_API_BASE_URL || "http://localhost:5000/api/";

const api = axios.create({
baseURL: URL,
Expand All @@ -21,7 +21,7 @@ api.interceptors.request.use((config) => {

export const postNote = async (newNote: NoteType) => {
const response = await api.post(
URL,
'notes',
{
title: newNote.title,
content: newNote.content,
Expand All @@ -32,7 +32,7 @@ export const postNote = async (newNote: NoteType) => {

export const patchNote = async (updatedNote: NoteType) => {
const response = await api.put(
`${URL}/${updatedNote.id}`,
`notes/${updatedNote.id}`,
{
title: updatedNote.title,
content: updatedNote.content,
Expand All @@ -42,18 +42,18 @@ export const patchNote = async (updatedNote: NoteType) => {
};

export const removeNote = async (id: number) => {
const response = await api.delete(`${URL}/${id}`);
const response = await api.delete(`notes/${id}`);
return response;
};

export const getNotes = async () => {
const response = await api.get(URL);
const response = await api.get('notes');
return response;
};

export const login = async (username: string, password: string) => {
const response = await axios.post(
"http://localhost:5000/api/login",
const response = await api.post(
'login',
{
username,
password,
Expand Down

2 comments on commit 721878a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

97.73%

Coverage Report
FileBranchesFuncsLinesUncovered Lines
src
   authenticateToken.ts100%100%100%
   index.ts96.77%90%97.33%165–167
   prisma.ts100%100%100%
src/__mocks__
   prisma.ts100%100%100%

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

91.43%

Coverage Report
FileBranchesFuncsLinesUncovered Lines
src
   App.tsx0%0%0%1, 1, 10–19, 2, 20–27, 3–9
   NoteApp.tsx94.12%100%96.69%66–70
src/api
   apiService.ts90.91%100%100%18
src/components
   Header.tsx0%0%0%1, 1–9
   Login.tsx100%100%100%
   Note.tsx100%100%100%
   NoteForm.tsx100%100%100%
   NoteFormModal.tsx100%100%100%
   NoteGrid.tsx100%100%100%
   Spinner.tsx100%100%100%

Please sign in to comment.