Skip to content

Commit

Permalink
fix: seperate services
Browse files Browse the repository at this point in the history
  • Loading branch information
abdahmed22 committed Aug 22, 2024
1 parent 1d0b80c commit e3ec58b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 36 deletions.
18 changes: 18 additions & 0 deletions client/src/api/ProjectService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { AuthClient } from './clients'
import { Project } from '@/types/types'

export async function postProject (project :Partial<Project>) {
return AuthClient.post('/dashboard/projects/', project)
}

export async function getProjects (page :number) {
return AuthClient.get('/dashboard/projects/', {
params: {
cursor: page,
},
})
}

export async function searchProject (searchInput: string) {
await AuthClient.get(`/project/search/${searchInput}`)
}
15 changes: 15 additions & 0 deletions client/src/api/clients.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import axios, { AxiosInstance } from 'axios'

export const AuthClient: AxiosInstance = axios.create({
baseURL: window.env.SERVER_DOMAIN_NAME_API,
timeout: 1000,
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzIzOTk0NzQ5LCJpYXQiOjE3MjM5ODU0NDksImp0aSI6ImRjMWRjMDU1ZTgzZjQ0NGQ4NDU1NTAwMGMyNDUwMTJhIiwidXNlcl9pZCI6NCwiZW1haWwiOiJib3VkaWVAYm91ZGllLmNvbSJ9.OgeODfFg5GxP1QxAAyu2FFlOMx2suAdWvjBtkK5eT0U',
},
})

export const BaseClient: AxiosInstance = axios.create({
baseURL: window.env.SERVER_DOMAIN_NAME_API,
timeout: 1000,
})
34 changes: 0 additions & 34 deletions client/src/api/userservice.ts

This file was deleted.

2 changes: 1 addition & 1 deletion client/src/components/projects/ProjectForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<script lang="ts">
import { ref } from 'vue'
import { postProject } from '@/api/userservice'
import { postProject } from '@/api/ProjectService'
import { Project } from '@/types/types'
import { descriptionRules, githubRepoRules, titleRules } from '@/utilities/validators'
import { useNotifier } from 'vue3-notifier'
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/projects/ProjectsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

<script lang="ts">
import { ref, watch } from 'vue'
import { getProjects, searchProject } from '@/api/userservice'
import { getProjects, searchProject } from '@/api/ProjectService'
import { useNotifier } from 'vue3-notifier'
import { Project } from '@/types/types'
import { RouterLink } from 'vue-router'
Expand Down

0 comments on commit e3ec58b

Please sign in to comment.