diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fde6ba9..6e6f015 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,8 +2,8 @@ name: "CI" on: push: - branches: [main] - pull_request: + branches: + - "**" jobs: build: @@ -11,17 +11,17 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [18] + node: [18, 20] steps: - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2.2.4 + - uses: pnpm/action-setup@v2 with: - version: 7.5.1 + version: 7 - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} cache: "pnpm" - - run: pnpm i + - run: pnpm i --frozen-lockfile - run: pnpm run ci - name: Coverage diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..3e775ef --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +auto-install-peers=true diff --git a/apps/example/.eslintrc.js b/apps/example/.eslintrc.js deleted file mode 100644 index df72793..0000000 --- a/apps/example/.eslintrc.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - rules: { - '@typescript-eslint/triple-slash-reference': 'off' - } -} diff --git a/apps/example/.eslintrc.json b/apps/example/.eslintrc.json new file mode 100644 index 0000000..c140af9 --- /dev/null +++ b/apps/example/.eslintrc.json @@ -0,0 +1,6 @@ +{ + "extends": "next/core-web-vitals", + "rules": { + "@typescript-eslint/triple-slash-reference": "off" + } +} diff --git a/apps/example/.gitignore b/apps/example/.gitignore new file mode 100644 index 0000000..fd3dbb5 --- /dev/null +++ b/apps/example/.gitignore @@ -0,0 +1,36 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js +.yarn/install-state.gz + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env*.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/apps/example/next.config.js b/apps/example/next.config.js index 3d3bc99..767719f 100644 --- a/apps/example/next.config.js +++ b/apps/example/next.config.js @@ -1,7 +1,4 @@ /** @type {import('next').NextConfig} */ -const nextConfig = { - reactStrictMode: true, - swcMinify: true, -}; +const nextConfig = {} -module.exports = nextConfig; +module.exports = nextConfig diff --git a/apps/example/package.json b/apps/example/package.json index cec69d1..e6913d2 100644 --- a/apps/example/package.json +++ b/apps/example/package.json @@ -5,12 +5,18 @@ "prebuild": "cd ../.. && pnpm build && cd apps/example", "dev": "pnpm prebuild && next dev", "build": "pnpm prebuild && next build", + "start": "next start", "generate": "pnpm prebuild && next-rest-framework generate --debug=true", "validate": "pnpm prebuild && next-rest-framework validate --debug=true", - "start": "next start", - "type-check": "tsc --noEmit" + "lint": "tsc && next lint" }, "dependencies": { "next-rest-framework": "workspace:*" + }, + "devDependencies": { + "autoprefixer": "10.0.1", + "postcss": "8.4.33", + "tailwindcss": "3.3.0", + "eslint-config-next": "14.0.4" } } diff --git a/apps/example/postcss.config.js b/apps/example/postcss.config.js new file mode 100644 index 0000000..33ad091 --- /dev/null +++ b/apps/example/postcss.config.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/apps/example/src/actions.ts b/apps/example/src/actions.ts index 42e7581..027e8d8 100644 --- a/apps/example/src/actions.ts +++ b/apps/example/src/actions.ts @@ -1,7 +1,7 @@ 'use server'; import { rpcOperation } from 'next-rest-framework'; -import { MOCK_TODOS, todoSchema } from 'utils'; +import { MOCK_TODOS, todoSchema } from '@/utils'; import { z } from 'zod'; // The RPC operations can be used as server-actions and imported in the RPC route handlers. diff --git a/apps/example/src/app/api/v2/rpc/[operationId]/route.ts b/apps/example/src/app/api/v2/rpc/[operationId]/route.ts index ddd0285..b2a9d0b 100644 --- a/apps/example/src/app/api/v2/rpc/[operationId]/route.ts +++ b/apps/example/src/app/api/v2/rpc/[operationId]/route.ts @@ -1,4 +1,4 @@ -import { createTodo, deleteTodo, getTodoById, getTodos } from 'actions'; +import { createTodo, deleteTodo, getTodoById, getTodos } from '@/actions'; import { rpcRoute } from 'next-rest-framework'; const { POST, client } = rpcRoute({ diff --git a/apps/example/src/app/api/v2/todos/route.ts b/apps/example/src/app/api/v2/todos/route.ts index d91c7fe..1c0f808 100644 --- a/apps/example/src/app/api/v2/todos/route.ts +++ b/apps/example/src/app/api/v2/todos/route.ts @@ -1,5 +1,5 @@ import { TypedNextResponse, route, routeOperation } from 'next-rest-framework'; -import { MOCK_TODOS, todoSchema } from 'utils'; +import { MOCK_TODOS, todoSchema } from '@/utils'; import { z } from 'zod'; // Example App Router route handler with GET/POST handlers. diff --git a/apps/example/src/app/client/ClientExample.tsx b/apps/example/src/app/client/ClientExample.tsx index 8683c56..9372459 100644 --- a/apps/example/src/app/client/ClientExample.tsx +++ b/apps/example/src/app/client/ClientExample.tsx @@ -1,9 +1,9 @@ 'use client'; -import { type RpcClient } from 'app/api/v2/rpc/[operationId]/route'; +import { type RpcClient } from '@/app/api/v2/rpc/[operationId]/route'; import { rpcClient } from 'next-rest-framework/dist/client/rpc-client'; import { useEffect, useState } from 'react'; -import { type Todo } from 'utils'; +import { type Todo } from '@/utils'; const client = rpcClient({ url: 'http://localhost:3000/api/v2/rpc' diff --git a/apps/example/src/app/client/page.tsx b/apps/example/src/app/client/page.tsx index 3347e14..feecec8 100644 --- a/apps/example/src/app/client/page.tsx +++ b/apps/example/src/app/client/page.tsx @@ -1,7 +1,7 @@ -import { getTodos } from 'actions'; -import { Footer } from '../components/Footer'; -import { Navbar } from '../components/Navbar'; -import { ClientExample } from './ClientExample'; +import { getTodos } from '@/actions'; +import { Footer } from '@/app/components/Footer'; +import { Navbar } from '@/app/components/Navbar'; +import { ClientExample } from '@/app/client/ClientExample'; export default async function Page() { const todos = await getTodos(); diff --git a/apps/example/src/app/components/Footer.tsx b/apps/example/src/app/components/Footer.tsx index 32726ab..fd5d26c 100644 --- a/apps/example/src/app/components/Footer.tsx +++ b/apps/example/src/app/components/Footer.tsx @@ -1,3 +1,5 @@ +import Image from 'next/image'; + export const Footer: React.FC = () => (