-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancement: Refactor server functions and files for better maintaina…
…bility (#264) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
8a08891
commit 86d6091
Showing
78 changed files
with
1,542 additions
and
1,177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,3 +137,6 @@ dist | |
.idea | ||
|
||
.config/shelve* | ||
|
||
*/dist/ | ||
*/.output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/HugoRCD/shelve/main/packages/types/shelveConfigSchema.json", | ||
"project": "shelve" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { H3Event } from 'h3' | ||
import { getUserByAuthToken } from '~~/server/app/tokenService' | ||
import type { H3Event } from 'h3' | ||
import { TokenService } from '~~/server/services/token.service' | ||
|
||
export default eventHandler(async (event: H3Event) => { | ||
const tokenService = new TokenService() | ||
const authToken = getCookie(event, 'authToken') || '' | ||
|
||
return await getUserByAuthToken(authToken) | ||
return await tokenService.getUserByAuthToken(authToken) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { H3Event } from 'h3' | ||
import { getUserRepos } from '~~/server/app/githubService' | ||
import type { H3Event } from 'h3' | ||
import { GitHubService } from '~~/server/services/github.service' | ||
|
||
export default defineEventHandler(async (event: H3Event) => { | ||
return await getUserRepos(event) | ||
const githubService = new GitHubService() | ||
return await githubService.getUserRepos(event) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { H3Event } from 'h3' | ||
import { getProjectById } from '~~/server/app/projectService' | ||
import type { H3Event } from 'h3' | ||
import { ProjectService } from '~~/server/services/project.service' | ||
|
||
export default eventHandler(async (event: H3Event) => { | ||
const id = getRouterParam(event, 'id') as string | ||
if (!id) throw createError({ statusCode: 400, statusMessage: 'Missing params' }) | ||
return await getProjectById(parseInt(id)) | ||
const projectService = new ProjectService() | ||
return await projectService.getProjectById(+id) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import { H3Event } from 'h3' | ||
import { updateProject } from '~~/server/app/projectService' | ||
import type { H3Event } from 'h3' | ||
import { ProjectService } from '~~/server/services/project.service' | ||
|
||
export default eventHandler(async (event: H3Event) => { | ||
const { user } = event.context | ||
const id = getRouterParam(event, 'id') as string | ||
if (!id) throw createError({ statusCode: 400, statusMessage: 'Missing params' }) | ||
const projectService = new ProjectService() | ||
const projectUpdateInput = await readBody(event) | ||
delete projectUpdateInput.variables | ||
delete projectUpdateInput.team | ||
projectUpdateInput.name = projectUpdateInput.name.trim() | ||
return await updateProject(projectUpdateInput, parseInt(id), user.id) | ||
return await projectService.updateProject(projectUpdateInput, +id, user.id) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { H3Event } from 'h3' | ||
import { getProjectsByUserId } from '~~/server/app/projectService' | ||
import type { H3Event } from 'h3' | ||
import { ProjectService } from '~~/server/services/project.service' | ||
|
||
export default eventHandler(async (event: H3Event) => { | ||
const projectService = new ProjectService() | ||
const { user } = event.context | ||
if (!user) throw createError({ statusCode: 401, message: 'Unauthorized' }) | ||
return await getProjectsByUserId(user.id) | ||
return await projectService.getProjectsByUserId(user.id) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { H3Event } from 'h3' | ||
import { createProject } from '~~/server/app/projectService' | ||
import type { H3Event } from 'h3' | ||
import { ProjectService } from '~~/server/services/project.service' | ||
|
||
export default eventHandler(async (event: H3Event) => { | ||
const projectService = new ProjectService() | ||
const { user } = event.context | ||
const projectCreateInput = await readBody(event) | ||
delete projectCreateInput.variables | ||
projectCreateInput.name = projectCreateInput.name.trim() | ||
return await createProject(projectCreateInput, user.id) | ||
return await projectService.createProject(projectCreateInput, user.id) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { H3Event } from 'h3' | ||
import { upsertMember } from '~~/server/app/teamsService' | ||
import type { H3Event } from 'h3' | ||
import { TeamService } from '~~/server/services/teams.service' | ||
|
||
export default eventHandler(async (event: H3Event) => { | ||
const { user } = event.context | ||
const teamId = getRouterParam(event, 'teamId') as string | ||
if (!teamId) throw createError({ statusCode: 400, statusMessage: 'Missing params' }) | ||
const teamService = new TeamService() | ||
const addMemberInput = await readBody(event) | ||
return await upsertMember(parseInt(teamId), addMemberInput, user.id) | ||
return await teamService.upsertMember(+teamId, addMemberInput, user.id) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { H3Event } from 'h3' | ||
import { getTeamByUserId } from '~~/server/app/teamsService' | ||
import type { H3Event } from 'h3' | ||
import { TeamService } from '~~/server/services/teams.service' | ||
|
||
export default eventHandler((event: H3Event) => { | ||
const teamService = new TeamService() | ||
const { user } = event.context | ||
return getTeamByUserId(user.id) | ||
return teamService.getTeamByUserId(user.id) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { H3Event } from 'h3' | ||
import type { H3Event } from 'h3' | ||
import type { CreateTeamInput } from '@shelve/types' | ||
import { createTeam } from '~~/server/app/teamsService' | ||
import { TeamService } from '~~/server/services/teams.service' | ||
|
||
export default eventHandler(async (event: H3Event) => { | ||
const { user } = event.context | ||
const createTeamInput = await readBody(event) as CreateTeamInput | ||
if (!createTeamInput.name) throw createError({ statusCode: 400, statusMessage: 'Cannot create team without name' }) | ||
const teamService = new TeamService() | ||
createTeamInput.name = createTeamInput.name.trim() | ||
return await createTeam(createTeamInput, user.id) | ||
return await teamService.createTeam(createTeamInput, user.id) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
import { H3Event } from 'h3' | ||
|
||
import type { H3Event } from 'h3' | ||
import { TokenService } from '~~/server/services/token.service' | ||
|
||
export default defineEventHandler(async (event: H3Event) => { | ||
const tokenService = new TokenService() | ||
const { user } = event.context | ||
const id = getRouterParam(event, 'id') as string | ||
|
||
if (!id) throw createError({ statusCode: 400, statusMessage: 'Missing params' }) | ||
|
||
await prisma.token.delete({ | ||
where: { | ||
id: +id, | ||
userId: user.id, | ||
}, | ||
}) | ||
await tokenService.deleteUserToken(+id, user.id) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { H3Event } from 'h3' | ||
import { getUserByAuthToken } from '~~/server/app/tokenService' | ||
import type { H3Event } from 'h3' | ||
import { TokenService } from '~~/server/services/token.service' | ||
|
||
export default defineEventHandler((event: H3Event) => { | ||
const tokenService = new TokenService() | ||
const token = getRouterParam(event, 'token') as string | ||
if (!token) throw createError({ statusCode: 400, statusMessage: 'Missing params' }) | ||
|
||
return getUserByAuthToken(token) | ||
return tokenService.getUserByAuthToken(token) | ||
}) |
Oops, something went wrong.