mirror of
https://github.com/documenso/documenso.git
synced 2025-11-20 11:41:44 +10:00
wip
This commit is contained in:
2
apps/remix/.gitignore
vendored
2
apps/remix/.gitignore
vendored
@ -6,4 +6,4 @@
|
|||||||
/build/
|
/build/
|
||||||
|
|
||||||
# Vite
|
# Vite
|
||||||
vite.config.ts.timestamp*
|
vite.config.*.timestamp*
|
||||||
@ -1,10 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@documenso/remix",
|
"name": "@documenso/remix",
|
||||||
"type": "module",
|
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cross-env NODE_ENV=production react-router build",
|
"build": "cross-env NODE_ENV=production react-router build",
|
||||||
"dev": "tsx watch --ignore \"vite.config.ts*\" server/main.ts",
|
"dev": "tsx watch --ignore \"vite.config.{ts,mts,js,mjs}*\" server/main.ts",
|
||||||
"start": "cross-env NODE_ENV=production node dist/server/index.js",
|
"start": "cross-env NODE_ENV=production node dist/server/index.js",
|
||||||
"typecheck": "react-router typegen && tsc"
|
"typecheck": "react-router typegen && tsc"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -3,15 +3,17 @@ import { type HttpBindings } from '@hono/node-server';
|
|||||||
import { Hono } from 'hono';
|
import { Hono } from 'hono';
|
||||||
import { reactRouter } from 'remix-hono/handler';
|
import { reactRouter } from 'remix-hono/handler';
|
||||||
|
|
||||||
type Bindings = HttpBindings;
|
import { IS_APP_WEB } from '@documenso/lib/constants/app';
|
||||||
|
|
||||||
const app = new Hono<{ Bindings: Bindings }>();
|
console.log({ IS_APP_WEB });
|
||||||
|
|
||||||
|
type Bindings = HttpBindings;
|
||||||
|
|
||||||
const isProduction = process.env.NODE_ENV === 'production';
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
|
|
||||||
const viteDevServer = isProduction
|
const viteDevServer = isProduction
|
||||||
? undefined
|
? undefined
|
||||||
: await import('vite').then(async (vite) =>
|
: import('vite').then(async (vite) =>
|
||||||
vite.createServer({
|
vite.createServer({
|
||||||
server: { middlewareMode: true },
|
server: { middlewareMode: true },
|
||||||
}),
|
}),
|
||||||
@ -23,23 +25,29 @@ const reactRouterMiddleware = remember('reactRouterMiddleware', async () =>
|
|||||||
build: isProduction
|
build: isProduction
|
||||||
? // @ts-expect-error build/server/index.js is a build artifact
|
? // @ts-expect-error build/server/index.js is a build artifact
|
||||||
await import('../build/server/index.js')
|
await import('../build/server/index.js')
|
||||||
: async () => viteDevServer!.ssrLoadModule('virtual:react-router/server-build'),
|
: async () => (await viteDevServer)!.ssrLoadModule('virtual:react-router/server-build'),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
// app.get('/', (c) => c.text('Hello, world!'));
|
export const getApp = async () => {
|
||||||
if (viteDevServer) {
|
const app = new Hono<{ Bindings: Bindings }>();
|
||||||
|
|
||||||
|
const resolvedDevServer = await viteDevServer;
|
||||||
|
|
||||||
|
// app.get('/', (c) => c.text('Hello, world!'));
|
||||||
|
if (resolvedDevServer) {
|
||||||
app.use('*', async (c, next) => {
|
app.use('*', async (c, next) => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
viteDevServer.middlewares(c.env.incoming, c.env.outgoing, () => resolve(next()));
|
resolvedDevServer.middlewares(c.env.incoming, c.env.outgoing, () => resolve(next()));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
app.use('*', async (c, next) => {
|
app.use('*', async (c, next) => {
|
||||||
const middleware = await reactRouterMiddleware;
|
const middleware = await reactRouterMiddleware;
|
||||||
|
|
||||||
return middleware(c, next);
|
return middleware(c, next);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default app;
|
return app;
|
||||||
|
};
|
||||||
|
|||||||
@ -1,7 +1,16 @@
|
|||||||
import { serve } from '@hono/node-server';
|
import { serve } from '@hono/node-server';
|
||||||
|
|
||||||
import app from './app';
|
import { getApp } from './app';
|
||||||
|
|
||||||
serve(app, (info) => {
|
async function main() {
|
||||||
|
const app = await getApp();
|
||||||
|
|
||||||
|
serve(app, (info) => {
|
||||||
console.log(`Server is running on http://localhost:${info.port}`);
|
console.log(`Server is running on http://localhost:${info.port}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((error) => {
|
||||||
|
console.error('Failed to start server:', error);
|
||||||
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,20 +6,33 @@
|
|||||||
".react-router/types/**/*"
|
".react-router/types/**/*"
|
||||||
],
|
],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["DOM", "DOM.Iterable", "ES2022"],
|
"lib": [
|
||||||
"types": ["node", "vite/client"],
|
"DOM",
|
||||||
|
"DOM.Iterable",
|
||||||
|
"ES2022"
|
||||||
|
],
|
||||||
|
"types": [
|
||||||
|
"node",
|
||||||
|
"vite/client"
|
||||||
|
],
|
||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"module": "ES2022",
|
"module": "ES2022",
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"rootDirs": [".", "./.react-router/types"],
|
"rootDirs": [
|
||||||
|
".",
|
||||||
|
"./.react-router/types"
|
||||||
|
],
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"~/*": ["./app/*"]
|
"~/*": [
|
||||||
|
"./app/*"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"verbatimModuleSyntax": true,
|
"verbatimModuleSyntax": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
|
"moduleDetection": "force",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strict": true
|
"strict": true
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
// @ts-expect-error This is just due to our root config, it's a non-issue
|
||||||
import { reactRouter } from '@react-router/dev/vite';
|
import { reactRouter } from '@react-router/dev/vite';
|
||||||
import autoprefixer from 'autoprefixer';
|
import autoprefixer from 'autoprefixer';
|
||||||
import tailwindcss from 'tailwindcss';
|
import tailwindcss from 'tailwindcss';
|
||||||
Reference in New Issue
Block a user