Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions e2e/react-start/server-functions/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { Route as AbortSignalRouteImport } from './routes/abort-signal'
import { Route as IndexRouteImport } from './routes/index'
import { Route as MiddlewareIndexRouteImport } from './routes/middleware/index'
import { Route as FormdataRedirectIndexRouteImport } from './routes/formdata-redirect/index'
import { Route as FactoryIndexRouteImport } from './routes/factory/index'
import { Route as CookiesIndexRouteImport } from './routes/cookies/index'
import { Route as MiddlewareSendServerFnRouteImport } from './routes/middleware/send-serverFn'
import { Route as MiddlewareClientMiddlewareRouterRouteImport } from './routes/middleware/client-middleware-router'
Expand Down Expand Up @@ -105,6 +106,11 @@ const FormdataRedirectIndexRoute = FormdataRedirectIndexRouteImport.update({
path: '/formdata-redirect/',
getParentRoute: () => rootRouteImport,
} as any)
const FactoryIndexRoute = FactoryIndexRouteImport.update({
id: '/factory/',
path: '/factory/',
getParentRoute: () => rootRouteImport,
} as any)
const CookiesIndexRoute = CookiesIndexRouteImport.update({
id: '/cookies/',
path: '/cookies/',
Expand Down Expand Up @@ -151,6 +157,7 @@ export interface FileRoutesByFullPath {
'/middleware/client-middleware-router': typeof MiddlewareClientMiddlewareRouterRoute
'/middleware/send-serverFn': typeof MiddlewareSendServerFnRoute
'/cookies': typeof CookiesIndexRoute
'/factory': typeof FactoryIndexRoute
'/formdata-redirect': typeof FormdataRedirectIndexRoute
'/middleware': typeof MiddlewareIndexRoute
'/formdata-redirect/target/$name': typeof FormdataRedirectTargetNameRoute
Expand All @@ -173,6 +180,7 @@ export interface FileRoutesByTo {
'/middleware/client-middleware-router': typeof MiddlewareClientMiddlewareRouterRoute
'/middleware/send-serverFn': typeof MiddlewareSendServerFnRoute
'/cookies': typeof CookiesIndexRoute
'/factory': typeof FactoryIndexRoute
'/formdata-redirect': typeof FormdataRedirectIndexRoute
'/middleware': typeof MiddlewareIndexRoute
'/formdata-redirect/target/$name': typeof FormdataRedirectTargetNameRoute
Expand All @@ -196,6 +204,7 @@ export interface FileRoutesById {
'/middleware/client-middleware-router': typeof MiddlewareClientMiddlewareRouterRoute
'/middleware/send-serverFn': typeof MiddlewareSendServerFnRoute
'/cookies/': typeof CookiesIndexRoute
'/factory/': typeof FactoryIndexRoute
'/formdata-redirect/': typeof FormdataRedirectIndexRoute
'/middleware/': typeof MiddlewareIndexRoute
'/formdata-redirect/target/$name': typeof FormdataRedirectTargetNameRoute
Expand All @@ -220,6 +229,7 @@ export interface FileRouteTypes {
| '/middleware/client-middleware-router'
| '/middleware/send-serverFn'
| '/cookies'
| '/factory'
| '/formdata-redirect'
| '/middleware'
| '/formdata-redirect/target/$name'
Expand All @@ -242,6 +252,7 @@ export interface FileRouteTypes {
| '/middleware/client-middleware-router'
| '/middleware/send-serverFn'
| '/cookies'
| '/factory'
| '/formdata-redirect'
| '/middleware'
| '/formdata-redirect/target/$name'
Expand All @@ -264,6 +275,7 @@ export interface FileRouteTypes {
| '/middleware/client-middleware-router'
| '/middleware/send-serverFn'
| '/cookies/'
| '/factory/'
| '/formdata-redirect/'
| '/middleware/'
| '/formdata-redirect/target/$name'
Expand All @@ -287,6 +299,7 @@ export interface RootRouteChildren {
MiddlewareClientMiddlewareRouterRoute: typeof MiddlewareClientMiddlewareRouterRoute
MiddlewareSendServerFnRoute: typeof MiddlewareSendServerFnRoute
CookiesIndexRoute: typeof CookiesIndexRoute
FactoryIndexRoute: typeof FactoryIndexRoute
FormdataRedirectIndexRoute: typeof FormdataRedirectIndexRoute
MiddlewareIndexRoute: typeof MiddlewareIndexRoute
FormdataRedirectTargetNameRoute: typeof FormdataRedirectTargetNameRoute
Expand Down Expand Up @@ -399,6 +412,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof FormdataRedirectIndexRouteImport
parentRoute: typeof rootRouteImport
}
'/factory/': {
id: '/factory/'
path: '/factory'
fullPath: '/factory'
preLoaderRoute: typeof FactoryIndexRouteImport
parentRoute: typeof rootRouteImport
}
'/cookies/': {
id: '/cookies/'
path: '/cookies'
Expand Down Expand Up @@ -455,6 +475,7 @@ const rootRouteChildren: RootRouteChildren = {
MiddlewareClientMiddlewareRouterRoute: MiddlewareClientMiddlewareRouterRoute,
MiddlewareSendServerFnRoute: MiddlewareSendServerFnRoute,
CookiesIndexRoute: CookiesIndexRoute,
FactoryIndexRoute: FactoryIndexRoute,
FormdataRedirectIndexRoute: FormdataRedirectIndexRoute,
MiddlewareIndexRoute: MiddlewareIndexRoute,
FormdataRedirectTargetNameRoute: FormdataRedirectTargetNameRoute,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { createMiddleware } from '@tanstack/react-start'
import { createFooServerFn } from './createFooServerFn'

const barMiddleware = createMiddleware({ type: 'function' }).server(
({ next }) => {
console.log('Bar middleware triggered')
return next({
context: { bar: 'bar' } as const,
})
},
)

export const createBarServerFn = createFooServerFn().middleware([barMiddleware])

export const barFnInsideFactoryFile = createBarServerFn().handler(
({ context }) => {
return {
name: 'barFnInsideFactoryFile',
context,
}
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function createFakeFn() {
return {
handler: (cb: () => Promise<any>) => cb,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { createMiddleware, createServerFn } from '@tanstack/react-start'

const fooMiddleware = createMiddleware({ type: 'function' }).server(
({ next }) => {
console.log('Foo middleware triggered')
return next({
context: { foo: 'foo' } as const,
})
},
)

export const createFooServerFn = createServerFn().middleware([fooMiddleware])

export const fooFnInsideFactoryFile = createFooServerFn().handler(
async ({ context, method }) => {
console.log('fooFnInsideFactoryFile handler triggered', method)
return {
name: 'fooFnInsideFactoryFile',
context,
}
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { createMiddleware } from '@tanstack/react-start'
import { createBarServerFn } from './createBarServerFn'
import { createFooServerFn } from './createFooServerFn'
import { createFakeFn } from './createFakeFn'

export const fooFn = createFooServerFn().handler(({ context }) => {
return {
name: 'fooFn',
context,
}
})

export const fooFnPOST = createFooServerFn({ method: 'POST' }).handler(
({ context }) => {
return {
name: 'fooFnPOST',
context,
}
},
)

export const barFn = createBarServerFn().handler(({ context }) => {
return {
name: 'barFn',
context,
}
})

export const barFnPOST = createBarServerFn({ method: 'POST' }).handler(
({ context }) => {
return {
name: 'barFnPOST',
context,
}
},
)

const localMiddleware = createMiddleware({ type: 'function' }).server(
({ next }) => {
console.log('local middleware triggered')
return next({
context: { local: 'local' } as const,
})
},
)

const localFnFactory = createBarServerFn.middleware([localMiddleware])

const anotherMiddleware = createMiddleware({ type: 'function' }).server(
({ next }) => {
console.log('another middleware triggered')
return next({
context: { another: 'another' } as const,
})
},
)

export const localFn = localFnFactory()
.middleware([anotherMiddleware])
.handler(({ context }) => {
return {
name: 'localFn',
context,
}
})

export const localFnPOST = localFnFactory({ method: 'POST' })
.middleware([anotherMiddleware])
.handler(({ context }) => {
return {
name: 'localFnPOST',
context,
}
})

export const fakeFn = createFakeFn().handler(async () => {
return {
name: 'fakeFn',
window,
}
})
Loading
Loading