From 7abfb9950f718d7271dbc92e68d5b3f245085019 Mon Sep 17 00:00:00 2001 From: Saidev Dhal Date: Tue, 5 Nov 2024 23:53:11 +0530 Subject: [PATCH] hono api --- apps/api/.eslintrc.json | 3 -- apps/api/.gitignore | 57 ++++++++++++---------------- apps/api/Dockerfile | 16 -------- apps/api/README.md | 38 ++----------------- apps/api/api/index.ts | 14 +++++++ apps/api/app/route.ts | 7 ---- apps/api/next.config.ts | 13 ------- apps/api/package.json | 24 +++--------- apps/api/postcss.config.mjs | 8 ---- apps/api/public/favicon.ico | Bin 0 -> 15406 bytes apps/api/public/file.svg | 1 - apps/api/public/globe.svg | 1 - apps/api/public/next.svg | 1 - apps/api/public/vercel.svg | 1 - apps/api/public/window.svg | 1 - apps/api/src/app/404/page.tsx | 5 --- apps/api/src/app/api/hello/route.ts | 6 --- apps/api/src/app/error.tsx | 6 --- apps/api/src/app/layout.tsx | 7 ---- apps/api/src/app/page.tsx | 8 ---- apps/api/tailwind.config.ts | 19 ---------- apps/api/tsconfig.json | 27 +++---------- apps/api/vercel.json | 8 ++++ 23 files changed, 59 insertions(+), 212 deletions(-) delete mode 100644 apps/api/.eslintrc.json delete mode 100644 apps/api/Dockerfile create mode 100644 apps/api/api/index.ts delete mode 100644 apps/api/app/route.ts delete mode 100644 apps/api/next.config.ts delete mode 100644 apps/api/postcss.config.mjs create mode 100644 apps/api/public/favicon.ico delete mode 100644 apps/api/public/file.svg delete mode 100644 apps/api/public/globe.svg delete mode 100644 apps/api/public/next.svg delete mode 100644 apps/api/public/vercel.svg delete mode 100644 apps/api/public/window.svg delete mode 100644 apps/api/src/app/404/page.tsx delete mode 100644 apps/api/src/app/api/hello/route.ts delete mode 100644 apps/api/src/app/error.tsx delete mode 100644 apps/api/src/app/layout.tsx delete mode 100644 apps/api/src/app/page.tsx delete mode 100644 apps/api/tailwind.config.ts create mode 100644 apps/api/vercel.json diff --git a/apps/api/.eslintrc.json b/apps/api/.eslintrc.json deleted file mode 100644 index 3722418..0000000 --- a/apps/api/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["next/core-web-vitals", "next/typescript"] -} diff --git a/apps/api/.gitignore b/apps/api/.gitignore index 26b002a..2804238 100644 --- a/apps/api/.gitignore +++ b/apps/api/.gitignore @@ -1,40 +1,31 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins +# dev +.vercel/ +.yarn/ !.yarn/releases -!.yarn/versions - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug +.vscode/* +!.vscode/launch.json +!.vscode/*.code-snippets +.idea/workspace.xml +.idea/usage.statistics.xml +.idea/shelf + +# deps +node_modules/ + +# env +.env +.env.production + +# logs +logs/ +*.log npm-debug.log* yarn-debug.log* yarn-error.log* +pnpm-debug.log* +lerna-debug.log* -# env files (can opt-in for commiting if needed) -.env* +# misc +.DS_Store -# vercel .vercel - -# typescript -*.tsbuildinfo -next-env.d.ts diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile deleted file mode 100644 index c622531..0000000 --- a/apps/api/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM node:20.12.0-alpine3.19 - -WORKDIR /usr/src/app - -COPY package.json package-lock.json turbo.json tsconfig.json ./ - - -COPY apps ./apps -COPY packages ./packages - -RUN npm install - -RUN npm run build - - -CMD ["npm", "run", "start-api"] \ No newline at end of file diff --git a/apps/api/README.md b/apps/api/README.md index e215bc4..2196aa0 100644 --- a/apps/api/README.md +++ b/apps/api/README.md @@ -1,36 +1,4 @@ -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). - -## Getting Started - -First, run the development server: - -```bash -npm run dev -# or -yarn dev -# or -pnpm dev -# or -bun dev ``` - -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. - -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. - -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. - -## Learn More - -To learn more about Next.js, take a look at the following resources: - -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. - -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! - -## Deploy on Vercel - -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. - -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. +npm install +npm run start +``` diff --git a/apps/api/api/index.ts b/apps/api/api/index.ts new file mode 100644 index 0000000..05d4967 --- /dev/null +++ b/apps/api/api/index.ts @@ -0,0 +1,14 @@ +import { Hono } from 'hono' +import { handle } from 'hono/vercel' + +export const config = { + runtime: 'edge' +} + +const app = new Hono().basePath('/api') + +app.get('/', (c) => { + return c.json({ message: 'Hello Hono!' }) +}) + +export default handle(app) diff --git a/apps/api/app/route.ts b/apps/api/app/route.ts deleted file mode 100644 index 30b9115..0000000 --- a/apps/api/app/route.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Import the Next.js Response object -import { NextResponse } from 'next/server'; - -// Define the GET request handler -export async function GET() { - return NextResponse.json({ message: "Hello, Next.js!" }); -} diff --git a/apps/api/next.config.ts b/apps/api/next.config.ts deleted file mode 100644 index b39d782..0000000 --- a/apps/api/next.config.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { NextConfig } from "next"; - -const nextConfig: NextConfig = { - eslint: { - ignoreDuringBuilds: true, - }, - typescript: { - ignoreBuildErrors: true, - }, - reactStrictMode: true, -}; - -export default nextConfig; diff --git a/apps/api/package.json b/apps/api/package.json index 8cc4aa8..430634f 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -1,27 +1,13 @@ { "name": "api", - "version": "0.1.0", - "private": true, "scripts": { - "dev": "next dev --turbopack", - "build": "next build", - "start": "next start", - "lint": "next lint", - "start-api": " cd ./apps/api && npm start" + "start": "vercel dev", + "deploy": "vercel --prod" }, "dependencies": { - "react": "19.0.0-rc-02c0e824-20241028", - "react-dom": "19.0.0-rc-02c0e824-20241028", - "next": "15.0.2" + "hono": "^4.6.9" }, "devDependencies": { - "typescript": "^5", - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "postcss": "^8", - "tailwindcss": "^3.4.1", - "eslint": "^8", - "eslint-config-next": "15.0.2" + "vercel": "^32.4.1" } -} +} \ No newline at end of file diff --git a/apps/api/postcss.config.mjs b/apps/api/postcss.config.mjs deleted file mode 100644 index 1a69fd2..0000000 --- a/apps/api/postcss.config.mjs +++ /dev/null @@ -1,8 +0,0 @@ -/** @type {import('postcss-load-config').Config} */ -const config = { - plugins: { - tailwindcss: {}, - }, -}; - -export default config; diff --git a/apps/api/public/favicon.ico b/apps/api/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..543164354afc72a8b8de19830b6b9c06af58c0ae GIT binary patch literal 15406 zcmeHOdr(x@8NZ+)h{!{Yf~ZJHzz|{A<&7-MQ{D(dFls}51Y#7yNHo!C)>p7KjWw~Y zopdtOOgl}d|MZb*XPTxn&X{D(w05SQ{*jsVF=?xvnzqD_F|p#Wzi)TXa#^^*-Cd|{ zcV~Wc?m72-kMo^#&*S^fYFd~!ON)=!n5Jrv&(^ejP190S-TBM}O?#DP7K`Wo{hId9 zB2CL=9g>j3UC!jc<~KVJRbf`VN&J(zL0p_=!=|Y;AhHnq=M>=1vQ{8(50Kjnq_hAm zLsTKYJ`s=DQk2Xq#U1NT;NkP5k-HnkBwr)h^_v8KiKD=1;B+&jcu<@&a z{Q$u7Tlu}nnTTHAS)7R1oCq&HfcHe_+7keuv35V4lhNwmJDjkTJ8`T0IiUOqE;7%r z%-pZ~1P<1mz+d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&EWDQu=HJa~=cDzkFOZ?T>m+syzNatOsYjPhd%>#K}%@~Z_ zIWnWKZ(WIxE1s^j6L;9RXRCGjs0GHJJ}=ls`S)-Jib#h4sq z|K~~n!98q?uMGpqr*Fpmj4pgf^!3FW#-QZBn6F(Y%gfp)>$k+@e0aXQd=q#}GKfFk z%VM1JC}j;xymAz_xnd)x^_RW0w0#sW^3K?X%|X=M%Zf3>HpUN!Bz`y^CW=4$_J!Eq z!I;o$#_t6Z$9G`|-qUzw_6iN+LsmDITYB&Tf$<<`fYvip8%OoeyU$~ak9-3;-5APw zjJ}EK`f&_dcHvctxw^nJqW76)G8W2sR-9~2kT&Ks7OAI|ST65ne3N5mTJA_GlUR2n z*Vc#6Bv$Ofr%eCIGt6x{$H+dij<)q3FDfr>D}UBaYh!%{(q6UgLAjDMooPWoUMC>n z9nC{{C&g+Mza38Mn&hA?Uy_nz8 zfmw`QpJf?bF>LC;_5jfKrO|C@W=vV``Kmg)^yek}r+3^a-6hR(BC=#)xQFrgbX6|* z0q7&SQv4Lpv>wR1_7KO5j2&4YN}q9`cje5h!!;E{SG;B>9XrQy54M#)pPSIdCzs6NUv=G8k-`YFqfNvv~bbe>pBkrRoG^M7CbRbKF072PE-bCVwSL%3Aq#61&p zo!Pg%w@}MF1b-zk5jY2ZWIv46GppU?(&XEyJc2J&aO``*Jx+x{l^wwl@2NjBIk*2z z4Vg>0FMGF&<7O1t2A1FEe)+8JE|2Ti9fOtkfUc-J7~b?KF8O`8e+IjwgX4(*McB{( zB78!)?(#7G9q*FZW>AfQL{*(aTJw&Q)6Q4y{P^aF7qzSA?Xw2 fns@IT_Cadv^H^~AY8cWiWPy+cLKgV{w7|as=smC{ literal 0 HcmV?d00001 diff --git a/apps/api/public/file.svg b/apps/api/public/file.svg deleted file mode 100644 index 004145c..0000000 --- a/apps/api/public/file.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apps/api/public/globe.svg b/apps/api/public/globe.svg deleted file mode 100644 index 567f17b..0000000 --- a/apps/api/public/globe.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apps/api/public/next.svg b/apps/api/public/next.svg deleted file mode 100644 index 5174b28..0000000 --- a/apps/api/public/next.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apps/api/public/vercel.svg b/apps/api/public/vercel.svg deleted file mode 100644 index 7705396..0000000 --- a/apps/api/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apps/api/public/window.svg b/apps/api/public/window.svg deleted file mode 100644 index b2b2a44..0000000 --- a/apps/api/public/window.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apps/api/src/app/404/page.tsx b/apps/api/src/app/404/page.tsx deleted file mode 100644 index ba507ca..0000000 --- a/apps/api/src/app/404/page.tsx +++ /dev/null @@ -1,5 +0,0 @@ -export default function Page404() { - return ( -
404
- ) -} \ No newline at end of file diff --git a/apps/api/src/app/api/hello/route.ts b/apps/api/src/app/api/hello/route.ts deleted file mode 100644 index b78c5c7..0000000 --- a/apps/api/src/app/api/hello/route.ts +++ /dev/null @@ -1,6 +0,0 @@ - -export function GET(req:Request) { - return new Response("Hello from Next.js on Vercel!", { - status: 200, - }); -} \ No newline at end of file diff --git a/apps/api/src/app/error.tsx b/apps/api/src/app/error.tsx deleted file mode 100644 index 478573a..0000000 --- a/apps/api/src/app/error.tsx +++ /dev/null @@ -1,6 +0,0 @@ -"use client" -export default function Error() { - return ( -
error
- ) -} \ No newline at end of file diff --git a/apps/api/src/app/layout.tsx b/apps/api/src/app/layout.tsx deleted file mode 100644 index 6c6f291..0000000 --- a/apps/api/src/app/layout.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export default function RootLayout({ children }: { children: React.ReactNode }) { - return ( - - {children} - - ) -} \ No newline at end of file diff --git a/apps/api/src/app/page.tsx b/apps/api/src/app/page.tsx deleted file mode 100644 index 21e600d..0000000 --- a/apps/api/src/app/page.tsx +++ /dev/null @@ -1,8 +0,0 @@ - -function page() { - return ( -
page
- ) -} - -export default page \ No newline at end of file diff --git a/apps/api/tailwind.config.ts b/apps/api/tailwind.config.ts deleted file mode 100644 index d43da91..0000000 --- a/apps/api/tailwind.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { Config } from "tailwindcss"; - -const config: Config = { - content: [ - "./pages/**/*.{js,ts,jsx,tsx,mdx}", - "./components/**/*.{js,ts,jsx,tsx,mdx}", - "./app/**/*.{js,ts,jsx,tsx,mdx}", - ], - theme: { - extend: { - colors: { - background: "var(--background)", - foreground: "var(--foreground)", - }, - }, - }, - plugins: [], -}; -export default config; diff --git a/apps/api/tsconfig.json b/apps/api/tsconfig.json index d8b9323..d52390f 100644 --- a/apps/api/tsconfig.json +++ b/apps/api/tsconfig.json @@ -1,27 +1,10 @@ { "compilerOptions": { - "target": "ES2017", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "node", + "esModuleInterop": true, "skipLibCheck": true, "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules"] -} +} \ No newline at end of file diff --git a/apps/api/vercel.json b/apps/api/vercel.json new file mode 100644 index 0000000..7f9ff0a --- /dev/null +++ b/apps/api/vercel.json @@ -0,0 +1,8 @@ +{ + "rewrites": [ + { + "source": "/api/(.*)", + "destination": "/api" + } + ] +} \ No newline at end of file