fix: hot update in dev mode! FINALLY

This commit is contained in:
Dhravya 2024-03-30 14:50:42 -07:00
parent f11a9cad2e
commit 2e6d1ce574
42 changed files with 8783 additions and 760 deletions

4
apps/web/.gitignore vendored
View file

@ -35,3 +35,7 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
# wrangler files
.wrangler
.dev.vars

View file

@ -1,34 +1,20 @@
{
"pages": {
"/page": [
"static/chunks/webpack.js",
"static/chunks/main-app.js",
"static/chunks/app/page.js"
],
"/layout": [
"static/chunks/webpack-3b758eebb48586bf.js",
"static/chunks/30b509c0-b94fb950b6812fcf.js",
"static/chunks/25-2a3c58bcd630d074.js",
"static/chunks/main-app-8b951cccf46caf8d.js",
"static/css/4af939cd84b2835e.css",
"static/chunks/app/layout-1db733038de334b4.js"
"static/chunks/webpack.js",
"static/chunks/main-app.js",
"static/css/app/layout.css",
"static/chunks/app/layout.js"
],
"/not-found": [
"static/chunks/webpack-3b758eebb48586bf.js",
"static/chunks/30b509c0-b94fb950b6812fcf.js",
"static/chunks/25-2a3c58bcd630d074.js",
"static/chunks/main-app-8b951cccf46caf8d.js",
"static/chunks/app/not-found-000997e9ed01307b.js"
],
"/privacy/page": [
"static/chunks/webpack-3b758eebb48586bf.js",
"static/chunks/30b509c0-b94fb950b6812fcf.js",
"static/chunks/25-2a3c58bcd630d074.js",
"static/chunks/main-app-8b951cccf46caf8d.js",
"static/chunks/app/privacy/page-a5b58ce70fc2df07.js"
],
"/page": [
"static/chunks/webpack-3b758eebb48586bf.js",
"static/chunks/30b509c0-b94fb950b6812fcf.js",
"static/chunks/25-2a3c58bcd630d074.js",
"static/chunks/main-app-8b951cccf46caf8d.js",
"static/chunks/574-80ad862bf72ba403.js",
"static/chunks/app/page-1e365ec6a3d98fff.js"
"static/chunks/webpack.js",
"static/chunks/main-app.js",
"static/chunks/app/not-found.js"
]
}
}

View file

@ -1,32 +1,19 @@
{
"polyfillFiles": [
"static/chunks/polyfills-c67a75d1b6f99dc8.js"
"static/chunks/polyfills.js"
],
"devFiles": [],
"ampDevFiles": [],
"lowPriorityFiles": [
"static/4GsSEk4YRHNK4h7UU2kGn/_buildManifest.js",
"static/4GsSEk4YRHNK4h7UU2kGn/_ssgManifest.js"
"static/development/_buildManifest.js",
"static/development/_ssgManifest.js"
],
"rootMainFiles": [
"static/chunks/webpack-3b758eebb48586bf.js",
"static/chunks/30b509c0-b94fb950b6812fcf.js",
"static/chunks/25-2a3c58bcd630d074.js",
"static/chunks/main-app-8b951cccf46caf8d.js"
"static/chunks/webpack.js",
"static/chunks/main-app.js"
],
"pages": {
"/_app": [
"static/chunks/webpack-3b758eebb48586bf.js",
"static/chunks/framework-c25027af42eb8c45.js",
"static/chunks/main-2bdce46f548bb672.js",
"static/chunks/pages/_app-508d387925ef2fa9.js"
],
"/_error": [
"static/chunks/webpack-3b758eebb48586bf.js",
"static/chunks/framework-c25027af42eb8c45.js",
"static/chunks/main-2bdce46f548bb672.js",
"static/chunks/pages/_error-e16765248192e4ee.js"
]
"/_app": []
},
"ampFirstPages": []
}

View file

@ -1 +0,0 @@
self.__PRERENDER_MANIFEST="{\"preview\":{\"previewModeId\":\"00a8552d79dec9ac01b5dcee85a28d34\",\"previewModeSigningKey\":\"d220867bd0bbea0b775a11a9ebcf53b0310ebb57c9ce7268703f6304da704123\",\"previewModeEncryptionKey\":\"b5cae6c2f97791f5a4376f88e95ff463ec34056005e14a949a462607974af14f\"}}"

View file

@ -1 +0,0 @@
{"version":3,"pages404":true,"caseSensitive":false,"basePath":"","redirects":[{"source":"/:path+/","destination":"/:path+","internal":true,"statusCode":308,"regex":"^(?:/((?:[^/]+?)(?:/(?:[^/]+?))*))/$"}],"headers":[],"dynamicRoutes":[{"page":"/api/[...nextauth]","regex":"^/api/(.+?)(?:/)?$","routeKeys":{"nxtPnextauth":"nxtPnextauth"},"namedRegex":"^/api/(?<nxtPnextauth>.+?)(?:/)?$"}],"staticRoutes":[{"page":"/","regex":"^/(?:/)?$","routeKeys":{},"namedRegex":"^/(?:/)?$"},{"page":"/_not-found","regex":"^/_not\\-found(?:/)?$","routeKeys":{},"namedRegex":"^/_not\\-found(?:/)?$"},{"page":"/favicon.ico","regex":"^/favicon\\.ico(?:/)?$","routeKeys":{},"namedRegex":"^/favicon\\.ico(?:/)?$"},{"page":"/privacy","regex":"^/privacy(?:/)?$","routeKeys":{},"namedRegex":"^/privacy(?:/)?$"}],"dataRoutes":[],"rsc":{"header":"RSC","varyHeader":"RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Url","prefetchHeader":"Next-Router-Prefetch","didPostponeHeader":"x-nextjs-postponed","contentTypeHeader":"text/x-component","suffix":".rsc","prefetchSuffix":".prefetch.rsc"},"rewrites":[]}

View file

@ -1,11 +1,5 @@
{
"/favicon.ico/route": "app/favicon.ico/route.js",
"/privacy/page": "app/privacy/page.js",
"/not-found": "app/not-found.js",
"/api/[...nextauth]/route": "app/api/[...nextauth]/route.js",
"/_not-found": "app/_not-found.js",
"/api/me/route": "app/api/me/route.js",
"/api/ask/route": "app/api/ask/route.js",
"/api/query/route": "app/api/query/route.js",
"/api/store/route": "app/api/store/route.js",
"/page": "app/page.js"
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +0,0 @@
[]

View file

@ -1 +1 @@
self.__BUILD_MANIFEST={polyfillFiles:["static/chunks/polyfills-c67a75d1b6f99dc8.js"],devFiles:[],ampDevFiles:[],lowPriorityFiles:["static/4GsSEk4YRHNK4h7UU2kGn/_buildManifest.js","static/4GsSEk4YRHNK4h7UU2kGn/_ssgManifest.js"],rootMainFiles:["static/chunks/webpack-3b758eebb48586bf.js","static/chunks/30b509c0-b94fb950b6812fcf.js","static/chunks/25-2a3c58bcd630d074.js","static/chunks/main-app-8b951cccf46caf8d.js"],pages:{"/_app":["static/chunks/webpack-3b758eebb48586bf.js","static/chunks/framework-c25027af42eb8c45.js","static/chunks/main-2bdce46f548bb672.js","static/chunks/pages/_app-508d387925ef2fa9.js"],"/_error":["static/chunks/webpack-3b758eebb48586bf.js","static/chunks/framework-c25027af42eb8c45.js","static/chunks/main-2bdce46f548bb672.js","static/chunks/pages/_error-e16765248192e4ee.js"]},ampFirstPages:[]};
self.__BUILD_MANIFEST={"polyfillFiles":["static/chunks/polyfills.js"],"devFiles":[],"ampDevFiles":[],"lowPriorityFiles":["static/development/_buildManifest.js","static/development/_ssgManifest.js"],"rootMainFiles":["static/chunks/webpack.js","static/chunks/main-app.js"],"pages":{"/_app":[]},"ampFirstPages":[]}

View file

@ -2,12 +2,32 @@
"sortedMiddleware": [],
"middleware": {},
"functions": {
"/not-found": {
"files": [
"server/server-reference-manifest.js",
"server/app/not-found_client-reference-manifest.js",
"server/middleware-build-manifest.js",
"server/middleware-react-loadable-manifest.js",
"server/next-font-manifest.js",
"server/edge-runtime-webpack.js",
"server/app/not-found.js"
],
"name": "app/not-found",
"page": "/not-found",
"matchers": [
{
"regexp": "^/not\\-found$",
"originalSource": "/not-found"
}
],
"wasm": [],
"assets": []
},
"/api/[...nextauth]/route": {
"files": [
"server/middleware-build-manifest.js",
"server/middleware-react-loadable-manifest.js",
"server/next-font-manifest.js",
"prerender-manifest.js",
"server/edge-runtime-webpack.js",
"server/app/api/[...nextauth]/route.js"
],
@ -22,108 +42,6 @@
"wasm": [],
"assets": []
},
"/_not-found": {
"files": [
"server/server-reference-manifest.js",
"server/app/_not-found_client-reference-manifest.js",
"server/middleware-build-manifest.js",
"server/middleware-react-loadable-manifest.js",
"server/next-font-manifest.js",
"prerender-manifest.js",
"server/edge-runtime-webpack.js",
"server/app/_not-found.js"
],
"name": "app/_not-found",
"page": "/_not-found",
"matchers": [
{
"regexp": "^/_not\\-found$",
"originalSource": "/_not-found"
}
],
"wasm": [],
"assets": []
},
"/api/me/route": {
"files": [
"server/middleware-build-manifest.js",
"server/middleware-react-loadable-manifest.js",
"server/next-font-manifest.js",
"prerender-manifest.js",
"server/edge-runtime-webpack.js",
"server/app/api/me/route.js"
],
"name": "app/api/me/route",
"page": "/api/me/route",
"matchers": [
{
"regexp": "^/api/me$",
"originalSource": "/api/me"
}
],
"wasm": [],
"assets": []
},
"/api/ask/route": {
"files": [
"server/middleware-build-manifest.js",
"server/middleware-react-loadable-manifest.js",
"server/next-font-manifest.js",
"prerender-manifest.js",
"server/edge-runtime-webpack.js",
"server/app/api/ask/route.js"
],
"name": "app/api/ask/route",
"page": "/api/ask/route",
"matchers": [
{
"regexp": "^/api/ask$",
"originalSource": "/api/ask"
}
],
"wasm": [],
"assets": []
},
"/api/query/route": {
"files": [
"server/middleware-build-manifest.js",
"server/middleware-react-loadable-manifest.js",
"server/next-font-manifest.js",
"prerender-manifest.js",
"server/edge-runtime-webpack.js",
"server/app/api/query/route.js"
],
"name": "app/api/query/route",
"page": "/api/query/route",
"matchers": [
{
"regexp": "^/api/query$",
"originalSource": "/api/query"
}
],
"wasm": [],
"assets": []
},
"/api/store/route": {
"files": [
"server/middleware-build-manifest.js",
"server/middleware-react-loadable-manifest.js",
"server/next-font-manifest.js",
"prerender-manifest.js",
"server/edge-runtime-webpack.js",
"server/app/api/store/route.js"
],
"name": "app/api/store/route",
"page": "/api/store/route",
"matchers": [
{
"regexp": "^/api/store$",
"originalSource": "/api/store"
}
],
"wasm": [],
"assets": []
},
"/page": {
"files": [
"server/server-reference-manifest.js",
@ -131,7 +49,6 @@
"server/middleware-build-manifest.js",
"server/middleware-react-loadable-manifest.js",
"server/next-font-manifest.js",
"prerender-manifest.js",
"server/edge-runtime-webpack.js",
"server/app/page.js"
],

View file

@ -1 +1 @@
self.__REACT_LOADABLE_MANIFEST="{}";
self.__REACT_LOADABLE_MANIFEST="{}"

View file

@ -1 +1 @@
self.__NEXT_FONT_MANIFEST='{"pages":{},"app":{"/Users/dhravyashah/Documents/code/anycontext/apps/web/src/app/layout":["static/media/c9a5bc6a7c948fb0-s.p.woff2"]},"appUsingSizeAdjust":true,"pagesUsingSizeAdjust":false}';
self.__NEXT_FONT_MANIFEST="{\"pages\":{},\"app\":{\"/Users/dhravyashah/Documents/code/anycontext/apps/web/src/app/layout\":[\"static/media/c9a5bc6a7c948fb0-s.p.woff2\"]},\"appUsingSizeAdjust\":true,\"pagesUsingSizeAdjust\":false}"

View file

@ -1,5 +1 @@
{
"/_app": "pages/_app.js",
"/_error": "pages/_error.js",
"/_document": "pages/_document.js"
}
{}

View file

@ -1 +0,0 @@
"use strict";(()=>{var e={};e.id=888,e.ids=[888],e.modules={3234:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return a}});let n=r(2460),o=r(997),i=n._(r(6689)),u=r(7071);async function s(e){let{Component:t,ctx:r}=e;return{pageProps:await (0,u.loadGetInitialProps)(t,r)}}class a extends i.default.Component{render(){let{Component:e,pageProps:t}=this.props;return(0,o.jsx)(e,{...t})}}a.origGetInitialProps=s,a.getInitialProps=s,("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},7071:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{WEB_VITALS:function(){return r},execOnce:function(){return n},isAbsoluteUrl:function(){return i},getLocationOrigin:function(){return u},getURL:function(){return s},getDisplayName:function(){return a},isResSent:function(){return c},normalizeRepeatedSlashes:function(){return l},loadGetInitialProps:function(){return f},SP:function(){return d},ST:function(){return p},DecodeError:function(){return g},NormalizeError:function(){return m},PageNotFoundError:function(){return P},MissingStaticPage:function(){return y},MiddlewareNotFoundError:function(){return E},stringifyError:function(){return x}});let r=["CLS","FCP","FID","INP","LCP","TTFB"];function n(e){let t,r=!1;return function(){for(var n=arguments.length,o=Array(n),i=0;i<n;i++)o[i]=arguments[i];return r||(r=!0,t=e(...o)),t}}let o=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,i=e=>o.test(e);function u(){let{protocol:e,hostname:t,port:r}=window.location;return e+"//"+t+(r?":"+r:"")}function s(){let{href:e}=window.location,t=u();return e.substring(t.length)}function a(e){return"string"==typeof e?e:e.displayName||e.name||"Unknown"}function c(e){return e.finished||e.headersSent}function l(e){let t=e.split("?");return t[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(t[1]?"?"+t.slice(1).join("?"):"")}async function f(e,t){let r=t.res||t.ctx&&t.ctx.res;if(!e.getInitialProps)return t.ctx&&t.Component?{pageProps:await f(t.Component,t.ctx)}:{};let n=await e.getInitialProps(t);if(r&&c(r))return n;if(!n)throw Error('"'+a(e)+'.getInitialProps()" should resolve to an object. But found "'+n+'" instead.');return n}let d="undefined"!=typeof performance,p=d&&["mark","measure","getEntriesByName"].every(e=>"function"==typeof performance[e]);class g extends Error{}class m extends Error{}class P extends Error{constructor(e){super(),this.code="ENOENT",this.name="PageNotFoundError",this.message="Cannot find module for page: "+e}}class y extends Error{constructor(e,t){super(),this.message="Failed to load static file for page: "+e+" "+t}}class E extends Error{constructor(){super(),this.code="ENOENT",this.message="Cannot find the middleware module"}}function x(e){return JSON.stringify({message:e.message,stack:e.stack})}},6689:e=>{e.exports=require("react")},997:e=>{e.exports=require("react/jsx-runtime")},2460:(e,t)=>{t._=t._interop_require_default=function(e){return e&&e.__esModule?e:{default:e}}}};var t=require("../webpack-runtime.js");t.C(e);var r=t(t.s=3234);module.exports=r})();

View file

@ -1 +0,0 @@
{"version":1,"files":["../webpack-runtime.js","../../../package.json","../../../node_modules/.pnpm/next@14.1.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/pages/_app.js"]}

View file

@ -1 +0,0 @@
"use strict";(()=>{var e={};e.id=660,e.ids=[660],e.modules={2785:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},6689:e=>{e.exports=require("react")},997:e=>{e.exports=require("react/jsx-runtime")},1017:e=>{e.exports=require("path")}};var r=require("../webpack-runtime.js");r.C(e);var s=e=>r(r.s=e),t=r.X(0,[72],()=>s(3072));module.exports=t})();

View file

@ -1 +0,0 @@
{"version":1,"files":["../webpack-runtime.js","../chunks/72.js","../../../package.json","../../../node_modules/.pnpm/next@14.1.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/pages/_document.js"]}

File diff suppressed because one or more lines are too long

View file

@ -1 +0,0 @@
{"version":1,"files":["../webpack-runtime.js","../chunks/72.js"]}

View file

@ -1 +1 @@
self.__RSC_SERVER_MANIFEST="{\"node\":{},\"edge\":{},\"encryptionKey\":\"lMIk9uVe7ojHQlK1M+Kk/x/kZPqRfvuRjUe2L5cC4/Y=\"}"
self.__RSC_SERVER_MANIFEST="{\n \"node\": {},\n \"edge\": {},\n \"encryptionKey\": \"W9uWR1/hXj4vReMVgs8KmMfKA8xn1NDBPuRIvYsR2BI=\"\n}"

View file

@ -1 +1,5 @@
{"node":{},"edge":{},"encryptionKey":"lMIk9uVe7ojHQlK1M+Kk/x/kZPqRfvuRjUe2L5cC4/Y="}
{
"node": {},
"edge": {},
"encryptionKey": "W9uWR1/hXj4vReMVgs8KmMfKA8xn1NDBPuRIvYsR2BI="
}

View file

@ -1 +0,0 @@
(()=>{"use strict";var e={},r={};function t(o){var n=r[o];if(void 0!==n)return n.exports;var a=r[o]={exports:{}},u=!0;try{e[o](a,a.exports,t),u=!1}finally{u&&delete r[o]}return a.exports}t.m=e,t.amdO={},t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},(()=>{var e,r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;t.t=function(o,n){if(1&n&&(o=this(o)),8&n||"object"==typeof o&&o&&(4&n&&o.__esModule||16&n&&"function"==typeof o.then))return o;var a=Object.create(null);t.r(a);var u={};e=e||[null,r({}),r([]),r(r)];for(var f=2&n&&o;"object"==typeof f&&!~e.indexOf(f);f=r(f))Object.getOwnPropertyNames(f).forEach(e=>u[e]=()=>o[e]);return u.default=()=>o,t.d(a,u),a}})(),t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.f={},t.e=e=>Promise.all(Object.keys(t.f).reduce((r,o)=>(t.f[o](e,r),r),[])),t.u=e=>""+e+".js",t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.X=(e,r,o)=>{var n=r;o||(r=e,o=()=>t(t.s=n)),r.map(t.e,t);var a=o();return void 0===a?e:a},(()=>{var e={658:1},r=r=>{var o=r.modules,n=r.ids,a=r.runtime;for(var u in o)t.o(o,u)&&(t.m[u]=o[u]);a&&a(t);for(var f=0;f<n.length;f++)e[n[f]]=1};t.f.require=(o,n)=>{e[o]||(658!=o?r(require("./chunks/"+t.u(o))):e[o]=1)},module.exports=t,t.C=r})()})();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,343 +0,0 @@
// File: /Users/dhravyashah/Documents/code/anycontext/apps/web/src/app/api/store/route.ts
import * as entry from '../../../../../src/app/api/store/route.js'
import type { NextRequest } from 'next/server.js'
type TEntry = typeof import('../../../../../src/app/api/store/route.js')
// Check that the entry is a valid entry
checkFields<Diff<{
GET?: Function
HEAD?: Function
OPTIONS?: Function
POST?: Function
PUT?: Function
DELETE?: Function
PATCH?: Function
config?: {}
generateStaticParams?: Function
revalidate?: RevalidateRange<TEntry> | false
dynamic?: 'auto' | 'force-dynamic' | 'error' | 'force-static'
dynamicParams?: boolean
fetchCache?: 'auto' | 'force-no-store' | 'only-no-store' | 'default-no-store' | 'default-cache' | 'only-cache' | 'force-cache'
preferredRegion?: 'auto' | 'global' | 'home' | string | string[]
runtime?: 'nodejs' | 'experimental-edge' | 'edge'
maxDuration?: number
}, TEntry, ''>>()
// Check the prop type of the entry function
if ('GET' in entry) {
checkFields<
Diff<
ParamCheck<Request | NextRequest>,
{
__tag__: 'GET'
__param_position__: 'first'
__param_type__: FirstArg<MaybeField<TEntry, 'GET'>>
},
'GET'
>
>()
checkFields<
Diff<
ParamCheck<PageParams>,
{
__tag__: 'GET'
__param_position__: 'second'
__param_type__: SecondArg<MaybeField<TEntry, 'GET'>>
},
'GET'
>
>()
checkFields<
Diff<
{
__tag__: 'GET',
__return_type__: Response | void | never | Promise<Response | void | never>
},
{
__tag__: 'GET',
__return_type__: ReturnType<MaybeField<TEntry, 'GET'>>
},
'GET'
>
>()
}
// Check the prop type of the entry function
if ('HEAD' in entry) {
checkFields<
Diff<
ParamCheck<Request | NextRequest>,
{
__tag__: 'HEAD'
__param_position__: 'first'
__param_type__: FirstArg<MaybeField<TEntry, 'HEAD'>>
},
'HEAD'
>
>()
checkFields<
Diff<
ParamCheck<PageParams>,
{
__tag__: 'HEAD'
__param_position__: 'second'
__param_type__: SecondArg<MaybeField<TEntry, 'HEAD'>>
},
'HEAD'
>
>()
checkFields<
Diff<
{
__tag__: 'HEAD',
__return_type__: Response | void | never | Promise<Response | void | never>
},
{
__tag__: 'HEAD',
__return_type__: ReturnType<MaybeField<TEntry, 'HEAD'>>
},
'HEAD'
>
>()
}
// Check the prop type of the entry function
if ('OPTIONS' in entry) {
checkFields<
Diff<
ParamCheck<Request | NextRequest>,
{
__tag__: 'OPTIONS'
__param_position__: 'first'
__param_type__: FirstArg<MaybeField<TEntry, 'OPTIONS'>>
},
'OPTIONS'
>
>()
checkFields<
Diff<
ParamCheck<PageParams>,
{
__tag__: 'OPTIONS'
__param_position__: 'second'
__param_type__: SecondArg<MaybeField<TEntry, 'OPTIONS'>>
},
'OPTIONS'
>
>()
checkFields<
Diff<
{
__tag__: 'OPTIONS',
__return_type__: Response | void | never | Promise<Response | void | never>
},
{
__tag__: 'OPTIONS',
__return_type__: ReturnType<MaybeField<TEntry, 'OPTIONS'>>
},
'OPTIONS'
>
>()
}
// Check the prop type of the entry function
if ('POST' in entry) {
checkFields<
Diff<
ParamCheck<Request | NextRequest>,
{
__tag__: 'POST'
__param_position__: 'first'
__param_type__: FirstArg<MaybeField<TEntry, 'POST'>>
},
'POST'
>
>()
checkFields<
Diff<
ParamCheck<PageParams>,
{
__tag__: 'POST'
__param_position__: 'second'
__param_type__: SecondArg<MaybeField<TEntry, 'POST'>>
},
'POST'
>
>()
checkFields<
Diff<
{
__tag__: 'POST',
__return_type__: Response | void | never | Promise<Response | void | never>
},
{
__tag__: 'POST',
__return_type__: ReturnType<MaybeField<TEntry, 'POST'>>
},
'POST'
>
>()
}
// Check the prop type of the entry function
if ('PUT' in entry) {
checkFields<
Diff<
ParamCheck<Request | NextRequest>,
{
__tag__: 'PUT'
__param_position__: 'first'
__param_type__: FirstArg<MaybeField<TEntry, 'PUT'>>
},
'PUT'
>
>()
checkFields<
Diff<
ParamCheck<PageParams>,
{
__tag__: 'PUT'
__param_position__: 'second'
__param_type__: SecondArg<MaybeField<TEntry, 'PUT'>>
},
'PUT'
>
>()
checkFields<
Diff<
{
__tag__: 'PUT',
__return_type__: Response | void | never | Promise<Response | void | never>
},
{
__tag__: 'PUT',
__return_type__: ReturnType<MaybeField<TEntry, 'PUT'>>
},
'PUT'
>
>()
}
// Check the prop type of the entry function
if ('DELETE' in entry) {
checkFields<
Diff<
ParamCheck<Request | NextRequest>,
{
__tag__: 'DELETE'
__param_position__: 'first'
__param_type__: FirstArg<MaybeField<TEntry, 'DELETE'>>
},
'DELETE'
>
>()
checkFields<
Diff<
ParamCheck<PageParams>,
{
__tag__: 'DELETE'
__param_position__: 'second'
__param_type__: SecondArg<MaybeField<TEntry, 'DELETE'>>
},
'DELETE'
>
>()
checkFields<
Diff<
{
__tag__: 'DELETE',
__return_type__: Response | void | never | Promise<Response | void | never>
},
{
__tag__: 'DELETE',
__return_type__: ReturnType<MaybeField<TEntry, 'DELETE'>>
},
'DELETE'
>
>()
}
// Check the prop type of the entry function
if ('PATCH' in entry) {
checkFields<
Diff<
ParamCheck<Request | NextRequest>,
{
__tag__: 'PATCH'
__param_position__: 'first'
__param_type__: FirstArg<MaybeField<TEntry, 'PATCH'>>
},
'PATCH'
>
>()
checkFields<
Diff<
ParamCheck<PageParams>,
{
__tag__: 'PATCH'
__param_position__: 'second'
__param_type__: SecondArg<MaybeField<TEntry, 'PATCH'>>
},
'PATCH'
>
>()
checkFields<
Diff<
{
__tag__: 'PATCH',
__return_type__: Response | void | never | Promise<Response | void | never>
},
{
__tag__: 'PATCH',
__return_type__: ReturnType<MaybeField<TEntry, 'PATCH'>>
},
'PATCH'
>
>()
}
// Check the arguments and return type of the generateStaticParams function
if ('generateStaticParams' in entry) {
checkFields<Diff<{ params: PageParams }, FirstArg<MaybeField<TEntry, 'generateStaticParams'>>, 'generateStaticParams'>>()
checkFields<Diff<{ __tag__: 'generateStaticParams', __return_type__: any[] | Promise<any[]> }, { __tag__: 'generateStaticParams', __return_type__: ReturnType<MaybeField<TEntry, 'generateStaticParams'>> }>>()
}
type PageParams = any
export interface PageProps {
params?: any
searchParams?: any
}
export interface LayoutProps {
children?: React.ReactNode
params?: any
}
// =============
// Utility types
type RevalidateRange<T> = T extends { revalidate: any } ? NonNegative<T['revalidate']> : never
// If T is unknown or any, it will be an empty {} type. Otherwise, it will be the same as Omit<T, keyof Base>.
type OmitWithTag<T, K extends keyof any, _M> = Omit<T, K>
type Diff<Base, T extends Base, Message extends string = ''> = 0 extends (1 & T) ? {} : OmitWithTag<T, keyof Base, Message>
type FirstArg<T extends Function> = T extends (...args: [infer T, any]) => any ? unknown extends T ? any : T : never
type SecondArg<T extends Function> = T extends (...args: [any, infer T]) => any ? unknown extends T ? any : T : never
type MaybeField<T, K extends string> = T extends { [k in K]: infer G } ? G extends Function ? G : never : never
type ParamCheck<T> = {
__tag__: string
__param_position__: string
__param_type__: T
}
function checkFields<_ extends { [k in keyof any]: never }>() {}
// https://github.com/sindresorhus/type-fest
type Numeric = number | bigint
type Zero = 0 | 0n
type Negative<T extends Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never
type NonNegative<T extends Numeric> = T extends Zero ? T : Negative<T> extends never ? T : '__invalid_negative_number__'

View file

@ -52,7 +52,17 @@ In order to enable the example:
```
# KV Example:
```
- If you're using TypeScript run the `build-cf-types` script to update the `env.d.ts` file:
```bash
npm run build-cf-types
# or
yarn build-cf-types
# or
pnpm build-cf-types
# or
bun build-cf-types
```
After doing this you can run the `dev` or `preview` script and visit the `/api/hello` route to see the example in action.
Finally, if you also want to see the example work in the deployed application make sure to add a `MY_KV` binding to your Pages application in its [dashboard kv bindings settings section](https://dash.cloudflare.com/?to=/:account/pages/view/:pages-project/settings/functions#kv_namespace_bindings_section). After having configured it make sure to re-deploy your application.
Finally, if you also want to see the example work in the deployed application make sure to add a `MY_KV_NAMESPACE` binding to your Pages application in its [dashboard kv bindings settings section](https://dash.cloudflare.com/?to=/:account/pages/view/:pages-project/settings/functions#kv_namespace_bindings_section). After having configured it make sure to re-deploy your application.

View file

@ -1,16 +1,16 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/app/globals.css",
"baseColor": "gray",
"cssVariables": false
},
"aliases": {
"utils": "@/lib/utils",
"components": "@/components"
}
}
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/app/globals.css",
"baseColor": "gray",
"cssVariables": false
},
"aliases": {
"utils": "@/lib/utils",
"components": "@/components"
}
}

67
apps/web/db/prepare.sql Normal file
View file

@ -0,0 +1,67 @@
CREATE TABLE `account` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`userId` text(255) NOT NULL,
`type` text(255) NOT NULL,
`provider` text(255) NOT NULL,
`providerAccountId` text(255) NOT NULL,
`refresh_token` text,
`access_token` text,
`expires_at` integer,
`token_type` text(255),
`scope` text(255),
`id_token` text,
`session_state` text(255),
`oauth_token_secret` text,
`oauth_token` text,
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `session` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`sessionToken` text(255) NOT NULL,
`userId` text(255) NOT NULL,
`expires` integer NOT NULL,
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `storedContent` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`content` text NOT NULL,
`title` text(255),
`description` text(255),
`url` text NOT NULL,
`savedAt` integer NOT NULL,
`baseUrl` text(255),
`image` text(255)
);
--> statement-breakpoint
CREATE TABLE `userStoredContent` (
`userId` text NOT NULL,
`contentId` integer NOT NULL,
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`contentId`) REFERENCES `storedContent`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `user` (
`id` text(255) PRIMARY KEY NOT NULL,
`name` text(255),
`email` text(255) NOT NULL,
`emailVerified` integer DEFAULT CURRENT_TIMESTAMP,
`image` text(255)
);
--> statement-breakpoint
CREATE TABLE `verificationToken` (
`identifier` text(255) NOT NULL,
`token` text(255) NOT NULL,
`expires` integer NOT NULL,
PRIMARY KEY(`identifier`, `token`)
);
--> statement-breakpoint
CREATE INDEX `account_userId_idx` ON `account` (`userId`);--> statement-breakpoint
CREATE INDEX `session_userId_idx` ON `session` (`userId`);--> statement-breakpoint
CREATE UNIQUE INDEX `storedContent_url_unique` ON `storedContent` (`url`);--> statement-breakpoint
CREATE INDEX `storedContent_url_idx` ON `storedContent` (`url`);--> statement-breakpoint
CREATE INDEX `storedContent_savedAt_idx` ON `storedContent` (`savedAt`);--> statement-breakpoint
CREATE INDEX `storedContent_title_idx` ON `storedContent` (`title`);--> statement-breakpoint
CREATE INDEX `userStoredContent_idx` ON `userStoredContent` (`userId`,`contentId`);--> statement-breakpoint
CREATE UNIQUE INDEX `unique_user_content` ON `userStoredContent` (`userId`,`contentId`);

18
apps/web/env.d.ts vendored
View file

@ -1,12 +1,12 @@
declare global {
namespace NodeJS {
interface ProcessEnv {
[key: string]: string | undefined;
DATABASE: D1Database;
VECTORIZE_INDEX: VectorizeIndex;
AI: any
namespace NodeJS {
interface ProcessEnv {
[key: string]: string | undefined;
DATABASE: D1Database;
VECTORIZE_INDEX: VectorizeIndex;
AI: any
}
}
}
}
export { };
export { };

View file

@ -1,4 +1,3 @@
import MillionLint from '@million/lint';
import { setupDevPlatform } from '@cloudflare/next-on-pages/next-dev';
// Here we use the @cloudflare/next-on-pages next-dev module to allow us to use bindings during local development
@ -10,6 +9,5 @@ if (process.env.NODE_ENV === 'development') {
/** @type {import('next').NextConfig} */
const nextConfig = {};
export default MillionLint.next({
rsc: true
})(nextConfig);
export default nextConfig;

View file

@ -3,44 +3,35 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev-arch": "next dev",
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"pages:build": "pnpm next-on-pages",
"dev": "pnpm pages:build && wrangler pages dev --live-reload .vercel/output/static --port=3000",
"deploy": "pnpm pages:build && wrangler pages deploy .vercel/output/static"
"pages:build": "bunx @cloudflare/next-on-pages",
"preview": "bun pages:build && wrangler pages dev .vercel/output/static",
"deploy": "bun pages:build && wrangler pages deploy .vercel/output/static",
"build-cf-types": "wrangler types --env-interface CloudflareEnv env.d.ts",
"prepare-local-db": "drizzle-kit generate:sqlite --out db/prepare.sql && wrangler d1 execute dev-d1-anycontext --local --file=db/prepare.sql"
},
"dependencies": {
"@million/lint": "latest",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-slot": "^1.0.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"lucide-react": "^0.338.0",
"next": "14.1.0",
"react": "^18",
"react-dom": "^18",
"tailwind-merge": "^2.2.1",
"tailwindcss-animate": "^1.0.7"
"next": "14.1.0"
},
"devDependencies": {
"@cloudflare/next-on-pages": "1",
"@cloudflare/workers-types": "^4.20240222.0",
"@cloudflare/workers-types": "^4.20240329.0",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.1.0",
"eslint-plugin-next-on-pages": "^1.9.0",
"eslint-plugin-next-on-pages": "^1.11.0",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^5",
"vercel": "^33.5.2",
"wrangler": "^3.29.0"
"vercel": "^33.6.2",
"wrangler": "^3.41.0"
}
}

View file

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="299" height="186" fill="none"><g clip-path="url(#a)"><rect width="299" height="186" fill="#292B2B" rx="3"/><g stroke="#C9C9C9" opacity=".5"><path d="m71.594 205.646 224-224M95.173 205.646l224-224M118.752 205.646l224-224M142.331 205.646l224-224M165.91 205.646l224-224M189.489 205.646l224-224M213.067 205.646l224-224M236.646 205.646l224-224M260.226 205.646l224-224M283.804 205.646l224-224M-211.354 205.646l224-224M-187.774 205.646l223.999-224M-164.196 205.646l224-224M-140.617 205.646l224-224M-117.038 205.646l224-224M-93.459 205.646l224-224M-69.88 205.646l224-224M-46.301 205.646l224-224M-22.722 205.646l224-224M.857 205.646l224-224M24.436 205.646l224-224M48.015 205.646l224-224M272.723 205.646l-224-224M249.144 205.646l-224-224M225.564 205.646l-224-224M201.985 205.646l-224-224M178.407 205.646l-224-224M154.828 205.646l-224-224M131.249 205.646l-224-224M107.67 205.646l-224-224M84.09 205.646l-224-224M60.511 205.646l-224-224M36.933 205.646l-224-224M13.354 205.646l-224-224M508.512 205.646l-224-224M484.933 205.646l-224-224M461.354 205.646l-224-224M437.775 205.646l-224-224M414.196 205.646l-224-224M390.617 205.646l-224-224M367.038 205.646l-224-224M343.459 205.646l-224-224M319.88 205.646l-224-224M296.3 205.646l-224-224"/></g><g stroke="#C9C9C9" opacity=".5"><path d="m83.594 205.646 224-224M107.173 205.646l224-224M130.752 205.646l224-224M154.331 205.646l224-224M177.91 205.646l224-224M201.489 205.646l224-224M225.067 205.646l224-224M248.646 205.646l224-224M272.226 205.646l224-224M295.804 205.646l224-224M-199.354 205.646l224-224M-175.774 205.646l223.999-224M-152.196 205.646l224-224M-128.617 205.646l224-224M-105.038 205.646l224-224M-81.459 205.646l224-224M-57.88 205.646l224-224M-34.301 205.646l224-224M-10.722 205.646l224-224M12.857 205.646l224-224M36.436 205.646l224-224M60.015 205.646l224-224M284.723 205.646l-224-224M261.144 205.646l-224-224M237.564 205.646l-224-224M213.985 205.646l-224-224M190.407 205.646l-224-224M166.828 205.646l-224-224M143.249 205.646l-224-224M119.67 205.646l-224-224M96.09 205.646l-224-224M72.511 205.646l-224-224M48.933 205.646l-224-224M25.354 205.646l-224-224M520.512 205.646l-224-224M496.933 205.646l-224-224M473.354 205.646l-224-224M449.775 205.646l-224-224M426.196 205.646l-224-224M402.617 205.646l-224-224M379.038 205.646l-224-224M355.459 205.646l-224-224M331.88 205.646l-224-224M308.3 205.646l-224-224"/></g></g><defs><clipPath id="a"><rect width="299" height="186" fill="#fff" rx="3"/></clipPath></defs></svg>

Before

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -19,11 +19,8 @@
],
"paths": {
"@/*": ["./src/*"]
},
"types": [
"@cloudflare/workers-types/2023-07-01"
]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
}