Skip to content

Commit

Permalink
create track queue, add types to api views, clean up model types
Browse files Browse the repository at this point in the history
  • Loading branch information
IkeHunter committed Sep 13, 2024
1 parent 8534281 commit 72d7204
Show file tree
Hide file tree
Showing 27 changed files with 1,031 additions and 757 deletions.
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

0 comments on commit 72d7204

Please sign in to comment.