-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use private org for location when set
- Loading branch information
Showing
6 changed files
with
70 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { TRPCError } from '@trpc/server' | ||
import { getConfig } from '../../bot/config' | ||
import { logger } from '../../utils/logger' | ||
import { GetConfigSchema } from './schema' | ||
|
||
const configApiLogger = logger.getSubLogger({ name: 'org-api' }) | ||
|
||
// Get the config values for the given org | ||
export const getConfigHandler = async ({ | ||
input, | ||
}: { | ||
input: GetConfigSchema | ||
}) => { | ||
try { | ||
configApiLogger.info('Fetching config', { ...input }) | ||
|
||
const config = await getConfig(input.orgId) | ||
|
||
configApiLogger.debug('Fetched config', config) | ||
|
||
return config | ||
} catch (error) { | ||
configApiLogger.error('Error fetching config', { error }) | ||
|
||
throw new TRPCError({ | ||
code: 'INTERNAL_SERVER_ERROR', | ||
message: (error as Error).message, | ||
}) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { procedure, router } from '../../utils/trpc-server' | ||
import { getConfigHandler } from './controller' | ||
import { GetConfigSchema } from './schema' | ||
|
||
const configRouter = router({ | ||
getConfig: procedure | ||
.input(GetConfigSchema) | ||
.query(({ input }) => getConfigHandler({ input })), | ||
}) | ||
|
||
export default configRouter |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { z } from 'zod' | ||
|
||
export const GetConfigSchema = z.object({ | ||
orgId: z.string(), | ||
}) | ||
|
||
export type GetConfigSchema = z.TypeOf<typeof GetConfigSchema> |