Skip to content

Commit

Permalink
Edge compability WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
blomqma committed Jan 10, 2024
1 parent 244d610 commit e0e6788
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/example/src/app/api/v2/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { docsRoute } from 'next-rest-framework';

export const runtime = 'edge';

export const { GET } = docsRoute({
deniedPaths: ['/api/routes/third-party-endpoint'],
openApiJsonPath: '/openapi.json'
Expand Down
2 changes: 2 additions & 0 deletions apps/example/src/app/api/v2/rpc/[operationId]/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { createTodo, deleteTodo, getTodoById, getTodos } from '@/actions';
import { rpcRoute } from 'next-rest-framework';

export const runtime = 'edge';

const { POST, client } = rpcRoute({
getTodos,
getTodoById,
Expand Down
2 changes: 2 additions & 0 deletions apps/example/src/app/api/v2/third-party-endpoint/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { NextResponse } from 'next/server';

export const runtime = 'edge';

// You can still write regular routes with Next REST Framework.
export const GET = () => {
return NextResponse.json('Server error', {
Expand Down
2 changes: 2 additions & 0 deletions apps/example/src/app/api/v2/todos/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { TypedNextResponse, route, routeOperation } from 'next-rest-framework';
import { z } from 'zod';

export const runtime = 'edge';

const TODOS = [
{
id: 1,
Expand Down
2 changes: 2 additions & 0 deletions apps/example/src/app/api/v2/todos/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { TypedNextResponse, route, routeOperation } from 'next-rest-framework';
import { MOCK_TODOS, todoSchema } from '@/utils';
import { z } from 'zod';

export const runtime = 'edge';

// Example App Router route handler with GET/POST handlers.
const { GET, POST } = route({
getTodos: routeOperation({
Expand Down
4 changes: 4 additions & 0 deletions apps/example/src/pages/api/v1/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { docsApiRoute } from 'next-rest-framework';

export const config = {
runtime: 'edge'
};

export default docsApiRoute({
deniedPaths: ['/api/routes/third-party-endpoint'],
openApiJsonPath: '/openapi.json',
Expand Down
4 changes: 4 additions & 0 deletions apps/example/src/pages/api/v1/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { createTodo, deleteTodo, getTodoById, getTodos } from '@/actions';
import { rpcApiRoute } from 'next-rest-framework';

export const config = {
runtime: 'edge'
};

const handler = rpcApiRoute({
getTodos,
getTodoById,
Expand Down
4 changes: 4 additions & 0 deletions apps/example/src/pages/api/v1/todos/[id].ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { apiRoute, apiRouteOperation } from 'next-rest-framework';
import { z } from 'zod';

export const config = {
runtime: 'edge'
};

const TODOS = [
{
id: 1,
Expand Down
4 changes: 4 additions & 0 deletions apps/example/src/pages/api/v1/todos/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { apiRoute, apiRouteOperation } from 'next-rest-framework';
import { z } from 'zod';

export const config = {
runtime: 'edge'
};

const TODOS = [
{
id: 1,
Expand Down

0 comments on commit e0e6788

Please sign in to comment.