mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-01-24 21:57:53 -05:00
* setting up test structure * . * added playwright config file, deleted original playwright folder and moved "some.test" file * continued test structure setup * Updating test folder structure * Added database seeding script and backend testing folder structure * removed the database test * Replaced db seeding script * Updated userInformation.ts to use values from choices.tsx * merge prep * removing extra unit test, moving api test to correct folder * Pushing to get help with sql Unit test * Updating get-profiles unit tests * Added more unit tests * . * Added more unit tests * Added getSupabaseToken unit test * . * excluding supabase token test so ci can pass * . * Seperated the seedDatabase func into its own file so it can be accessed seperatly * Fixed failing test * . * . * Fix tests * Fix lint * Clean --------- Co-authored-by: MartinBraquet <martin.braquet@gmail.com>
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { toUserAPIResponse } from 'common/api/user-types'
|
|
import { convertUser } from 'common/supabase/users'
|
|
import { createSupabaseDirectClient } from 'shared/supabase/init'
|
|
import { APIError } from 'common/api/utils'
|
|
|
|
export const getUser = async (props: { id: string } | { username: string }) => {
|
|
const pg = createSupabaseDirectClient()
|
|
const user = await pg.oneOrNone(
|
|
`select * from users
|
|
where ${'id' in props ? 'id' : 'username'} = $1`,
|
|
['id' in props ? props.id : props.username],
|
|
(r) => (r ? convertUser(r) : null)
|
|
)
|
|
if (!user) throw new APIError(404, 'User not found')
|
|
|
|
return toUserAPIResponse(user)
|
|
}
|
|
|
|
// export const getDisplayUser = async (
|
|
// props: { id: string } | { username: string }
|
|
// ) => {
|
|
// console.log('getDisplayUser', props)
|
|
// const pg = createSupabaseDirectClient()
|
|
// const liteUser = await pg.oneOrNone(
|
|
// `select ${displayUserColumns}
|
|
// from users
|
|
// where ${'id' in props ? 'id' : 'username'} = $1`,
|
|
// ['id' in props ? props.id : props.username]
|
|
// )
|
|
// if (!liteUser) throw new APIError(404, 'User not found')
|
|
//
|
|
// return removeNullOrUndefinedProps(liteUser)
|
|
// }
|