mirror of
https://github.com/docmost/docmost.git
synced 2025-11-10 09:12:05 +10:00
POC
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Docmost</title>
|
||||
<!--meta-tags-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@ -62,6 +62,13 @@ export default function App() {
|
||||
<>
|
||||
<Routes>
|
||||
<Route index element={<Navigate to="/home" />} />
|
||||
<Route path={"/share/:id"} element={
|
||||
<ErrorBoundary
|
||||
fallback={<>Failed to load home. An error occurred.</>}
|
||||
>
|
||||
<Home />
|
||||
</ErrorBoundary>
|
||||
}/>
|
||||
<Route path={"/login"} element={<LoginPage />} />
|
||||
<Route path={"/invites/:invitationId"} element={<InviteSignup />} />
|
||||
<Route path={"/setup/register"} element={<SetupWorkspace />} />
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { Controller, Get, Param, Res } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
import { FastifyReply } from "fastify";
|
||||
import { join } from 'path';
|
||||
import * as fs from 'node:fs';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
@ -9,4 +12,27 @@ export class AppController {
|
||||
getHello(): string {
|
||||
return this.appService.getHello();
|
||||
}
|
||||
|
||||
@Get('/share/:id')
|
||||
getShare(@Res({ passthrough: false}) res: FastifyReply, @Param() params: any): string {
|
||||
const clientDistPath = join(
|
||||
__dirname,
|
||||
'..',
|
||||
'..',
|
||||
'client/dist',
|
||||
);
|
||||
|
||||
if (fs.existsSync(clientDistPath)) {
|
||||
console.log('exists')
|
||||
const indexFilePath = join(clientDistPath, 'index.html');
|
||||
const stream = fs.createReadStream(indexFilePath);
|
||||
|
||||
console.log(params.id)
|
||||
res.type('text/html').send(stream);
|
||||
console.log('found');
|
||||
return;
|
||||
}
|
||||
console.log('end')
|
||||
return this.appService.getHello();
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ async function bootstrap() {
|
||||
},
|
||||
);
|
||||
|
||||
app.setGlobalPrefix('api');
|
||||
app.setGlobalPrefix('api', { exclude: ['share/:id']});
|
||||
|
||||
const redisIoAdapter = new WsRedisIoAdapter(app);
|
||||
await redisIoAdapter.connectToRedis();
|
||||
|
||||
Reference in New Issue
Block a user