Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track Queue, API View types #42

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/conventions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Project Conventions

## Objects, Models, Schemas

When handling objects in typescript, often it is useful to know if the object represents minimum fields required for creation, or the full list of fields given from the model serialization process. When differentiating between the two, stick with this convention:

For some model named `Model`,

- Use `IModel` to describe all possible fields, including the ID field
- Use `IModelFields` to describe fields needed when creating the model.
14 changes: 11 additions & 3 deletions server/controllers/groupController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ export const assignSpotifyToGroup = async (
return group
}

export const getGroupSpotify = async (groupId: string) => {
export const getGroupSpotifyAuth = async (groupId) => {
const group = await getOrError(groupId, Group)
const auth = await getOrError(group.spotifyAuthId?.toString() ?? '', SpotifyAuth)

return auth
}

export const getGroupSpotify = async (groupId: string) => {
const auth = await getGroupSpotifyAuth(groupId)
// const group = await getOrError(groupId, Group)

const auth = await SpotifyAuth.findById(group.spotifyAuthId)
if (!auth) throw new Error(`No linked Spotify accounts for group ${group.name}.`)
// const auth = await SpotifyAuth.findById(group.spotifyAuthId)
// if (!auth) throw new Error(`No linked Spotify accounts for group ${group.name}.`)

return SpotifyService.connect(auth.spotifyEmail)
}
Expand Down
1 change: 1 addition & 0 deletions server/controllers/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './groupController'
export * from './userController'
20 changes: 0 additions & 20 deletions server/controllers/jamController.ts

This file was deleted.

5 changes: 3 additions & 2 deletions server/docs/swagger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BASE_URL } from 'server/config'
import type { IGroup } from 'server/models'
import type { IGroup, IGroupFields } from 'server/models'
import { ResponseCodes, formatJsonResponse } from 'server/utils'
import swaggerAutogen from 'swagger-autogen'

Expand Down Expand Up @@ -43,7 +43,8 @@ const doc = {
}
},
definitions: {
Group: { name: '', ownerId: '' } as IGroup
IGroupFields: { name: '', ownerId: '' } as IGroupFields,
IGroup: { id: '', name: '', ownerId: '' } as IGroup
}
}
const generateResponseDocs = () => {
Expand Down
Loading