1+ import { type Route } from './+types/api.$'
12import path from 'node:path'
23import { invariantResponse } from '@epic-web/invariant'
34import { makeTimings } from '@epic-web/workshop-utils/timing.server'
45import fsExtra from 'fs-extra'
5- import {
6- redirect ,
7- type ActionFunctionArgs ,
8- type LoaderFunctionArgs ,
9- } from 'react-router'
6+ import { redirect } from 'react-router'
107import { z } from 'zod'
118import { compileTs } from '#app/utils/compile-app.server.ts'
129import { ensureUndeployed , getBaseUrl } from '#app/utils/misc.tsx'
1310import { resolveApps } from './__utils'
1411
15- export async function loader ( args : LoaderFunctionArgs ) {
12+ export async function loader ( args : Route . LoaderArgs ) {
1613 ensureUndeployed ( )
1714 const api = await getApiModule ( args )
1815 const loaderFn = api . mod . loader as
19- | ( ( loaderArgs : LoaderFunctionArgs ) => unknown )
16+ | ( ( loaderArgs : Route . LoaderArgs ) => unknown )
2017 | undefined
2118 invariantResponse (
2219 loaderFn ,
@@ -31,11 +28,11 @@ export async function loader(args: LoaderFunctionArgs) {
3128 }
3229}
3330
34- export async function action ( args : ActionFunctionArgs ) {
31+ export async function action ( args : Route . ActionArgs ) {
3532 ensureUndeployed ( )
3633 const api = await getApiModule ( args )
3734 const actionFn = api . mod . action as
38- | ( ( actionArgs : ActionFunctionArgs ) => unknown )
35+ | ( ( actionArgs : Route . ActionArgs ) => unknown )
3936 | undefined
4037 invariantResponse (
4138 actionFn ,
@@ -55,7 +52,7 @@ const ApiModuleSchema = z.object({
5552 action : z . function ( ) . optional ( ) ,
5653} )
5754
58- async function getApiModule ( { request, params } : LoaderFunctionArgs ) {
55+ async function getApiModule ( { request, params } : Route . LoaderArgs ) {
5956 const timings = makeTimings ( 'app-api' )
6057 const { fileApp, app } = await resolveApps ( { request, params, timings } )
6158 if ( ! fileApp || ! app ) {
0 commit comments