-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into IN-945-service-edit-page
- Loading branch information
Showing
7 changed files
with
42 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
import { defineRouter, publicProcedure } from '~api/lib/trpc' | ||
import { defineRouter, importHandler, publicProcedure } from '~api/lib/trpc' | ||
|
||
import * as schema from './schemas' | ||
|
||
const HandlerCache: Partial<GeoHandlerCache> = {} | ||
const NAMESPACE = 'geo' | ||
|
||
type GeoHandlerCache = { | ||
autocomplete: typeof import('./query.autocomplete.handler').autocomplete | ||
geoByPlaceId: typeof import('./query.geoByPlaceId.handler').geoByPlaceId | ||
} | ||
const namespaced = (s: string) => `${NAMESPACE}.${s}` | ||
|
||
export const geoRouter = defineRouter({ | ||
autocomplete: publicProcedure.input(schema.ZAutocompleteSchema).query(async ({ ctx, input }) => { | ||
if (!HandlerCache.autocomplete) | ||
HandlerCache.autocomplete = await import('./query.autocomplete.handler').then((mod) => mod.autocomplete) | ||
if (!HandlerCache.autocomplete) throw new Error('Failed to load handler') | ||
return HandlerCache.autocomplete({ ctx, input }) | ||
autocomplete: publicProcedure.input(schema.ZAutocompleteSchema).query(async (opts) => { | ||
const handler = await importHandler( | ||
namespaced('autocomplete'), | ||
() => import('./query.autocomplete.handler') | ||
) | ||
return handler(opts) | ||
}), | ||
geoByPlaceId: publicProcedure.input(schema.ZGeoByPlaceIdSchema).query(async ({ ctx, input }) => { | ||
if (!HandlerCache.geoByPlaceId) | ||
HandlerCache.geoByPlaceId = await import('./query.geoByPlaceId.handler').then((mod) => mod.geoByPlaceId) | ||
if (!HandlerCache.geoByPlaceId) throw new Error('Failed to load handler') | ||
return HandlerCache.geoByPlaceId({ ctx, input }) | ||
geoByPlaceId: publicProcedure.input(schema.ZGeoByPlaceIdSchema).query(async (opts) => { | ||
const handler = await importHandler( | ||
namespaced('geoByPlaceId'), | ||
() => import('./query.geoByPlaceId.handler') | ||
) | ||
return handler(opts) | ||
}), | ||
}) |
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,45 +1,32 @@ | ||
import { defineRouter, permissionedProcedure, publicProcedure } from '~api/lib/trpc' | ||
import { defineRouter, importHandler, permissionedProcedure, publicProcedure } from '~api/lib/trpc' | ||
|
||
import * as schema from './schemas' | ||
|
||
const HandlerCache: Partial<MiscHandlerCache> = {} | ||
|
||
type MiscHandlerCache = { | ||
hasContactInfo: typeof import('./query.hasContactInfo.handler').hasContactInfo | ||
getCountryTranslation: typeof import('./query.getCountryTranslation.handler').getCountryTranslation | ||
forEditNavbar: typeof import('./query.forEditNavbar.handler').forEditNavbar | ||
} | ||
const NAMESPACE = 'misc' | ||
|
||
const namespaced = (s: string) => `${NAMESPACE}.${s}` | ||
export const miscRouter = defineRouter({ | ||
hasContactInfo: publicProcedure.input(schema.ZHasContactInfoSchema).query(async ({ ctx, input }) => { | ||
if (!HandlerCache.hasContactInfo) | ||
HandlerCache.hasContactInfo = await import('./query.hasContactInfo.handler').then( | ||
(mod) => mod.hasContactInfo | ||
) | ||
|
||
if (!HandlerCache.hasContactInfo) throw new Error('Failed to load handler') | ||
return HandlerCache.hasContactInfo({ ctx, input }) | ||
hasContactInfo: publicProcedure.input(schema.ZHasContactInfoSchema).query(async (opts) => { | ||
const handler = await importHandler( | ||
namespaced('hasContactInfo'), | ||
() => import('./query.hasContactInfo.handler') | ||
) | ||
return handler(opts) | ||
}), | ||
getCountryTranslation: publicProcedure.input(schema.ZGetCountryTranslationSchema).query(async (opts) => { | ||
const handler = await importHandler( | ||
namespaced('getCountryTranslation'), | ||
() => import('./query.getCountryTranslation.handler') | ||
) | ||
return handler(opts) | ||
}), | ||
getCountryTranslation: publicProcedure | ||
.input(schema.ZGetCountryTranslationSchema) | ||
.query(async ({ ctx, input }) => { | ||
if (!HandlerCache.getCountryTranslation) | ||
HandlerCache.getCountryTranslation = await import('./query.getCountryTranslation.handler').then( | ||
(mod) => mod.getCountryTranslation | ||
) | ||
|
||
if (!HandlerCache.getCountryTranslation) throw new Error('Failed to load handler') | ||
return HandlerCache.getCountryTranslation({ ctx, input }) | ||
}), | ||
forEditNavbar: permissionedProcedure('updateLocation') | ||
.input(schema.ZForEditNavbarSchema) | ||
.query(async ({ ctx, input }) => { | ||
if (!HandlerCache.forEditNavbar) | ||
HandlerCache.forEditNavbar = await import('./query.forEditNavbar.handler').then( | ||
(mod) => mod.forEditNavbar | ||
) | ||
|
||
if (!HandlerCache.forEditNavbar) throw new Error('Failed to load handler') | ||
return HandlerCache.forEditNavbar({ ctx, input }) | ||
.query(async (opts) => { | ||
const handler = await importHandler( | ||
namespaced('forEditNavbar'), | ||
() => import('./query.forEditNavbar.handler') | ||
) | ||
return handler(opts) | ||
}), | ||
}) |
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