mirror of
https://github.com/docmost/docmost.git
synced 2025-11-11 13:32:05 +10:00
Compare commits
1 Commits
v0.6.2
...
poc/server
| Author | SHA1 | Date | |
|---|---|---|---|
| 5506fe5e73 |
@ -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>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "client",
|
||||
"private": true,
|
||||
"version": "0.6.2",
|
||||
"version": "0.6.1",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
|
||||
@ -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,6 +1,6 @@
|
||||
{
|
||||
"name": "server",
|
||||
"version": "0.6.2",
|
||||
"version": "0.6.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"private": true,
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ export class AttachmentController {
|
||||
const fileStream = await this.storageService.read(attachment.filePath);
|
||||
res.headers({
|
||||
'Content-Type': attachment.mimeType,
|
||||
'Cache-Control': 'private, max-age=3600',
|
||||
'Cache-Control': 'public, max-age=3600',
|
||||
});
|
||||
|
||||
if (!inlineFileExtensions.includes(attachment.fileExt)) {
|
||||
@ -299,7 +299,7 @@ export class AttachmentController {
|
||||
const fileStream = await this.storageService.read(filePath);
|
||||
res.headers({
|
||||
'Content-Type': getMimeType(filePath),
|
||||
'Cache-Control': 'private, max-age=86400',
|
||||
'Cache-Control': 'public, max-age=86400',
|
||||
});
|
||||
return res.send(fileStream);
|
||||
} catch (err) {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import {
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
Logger,
|
||||
UnauthorizedException,
|
||||
} from '@nestjs/common';
|
||||
import { PassportStrategy } from '@nestjs/passport';
|
||||
@ -14,8 +13,6 @@ import { FastifyRequest } from 'fastify';
|
||||
|
||||
@Injectable()
|
||||
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||
private logger = new Logger('JwtStrategy');
|
||||
|
||||
constructor(
|
||||
private userRepo: UserRepo,
|
||||
private workspaceRepo: WorkspaceRepo,
|
||||
@ -28,7 +25,7 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||
try {
|
||||
accessToken = JSON.parse(req.cookies?.authTokens)?.accessToken;
|
||||
} catch {
|
||||
this.logger.debug('Failed to parse access token');
|
||||
throw new BadRequestException('Failed to parse access token');
|
||||
}
|
||||
|
||||
return accessToken || this.extractTokenFromHeader(req);
|
||||
|
||||
@ -24,7 +24,7 @@ async function bootstrap() {
|
||||
},
|
||||
);
|
||||
|
||||
app.setGlobalPrefix('api');
|
||||
app.setGlobalPrefix('api', { exclude: ['share/:id']});
|
||||
|
||||
const redisIoAdapter = new WsRedisIoAdapter(app);
|
||||
await redisIoAdapter.connectToRedis();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "docmost",
|
||||
"homepage": "https://docmost.com",
|
||||
"version": "0.6.2",
|
||||
"version": "0.6.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "nx run-many -t build",
|
||||
|
||||
Reference in New Issue
Block a user