mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-26 22:32:23 +02:00
Duplicate CSS + Compression (#1071)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -13,7 +13,8 @@
|
||||
"docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/front staging",
|
||||
"docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/front",
|
||||
"lint": "eslint src",
|
||||
"format": "prettier --write src && eslint --fix src"
|
||||
"format": "prettier --write src && eslint --fix src",
|
||||
"run-local": "cross-env MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost TRANSACTOR_URL=ws:/localhost:3333 SERVER_SECRET='secret' ACCOUNTS_URL=http://localhost:3000 UPLOAD_URL=/files ELASTIC_URL=http://localhost:9200 MODEL_VERSION=$(node ../../models/all/lib/__showversion.js) PUBLIC_DIR='.' ts-node ./src/__start.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@anticrm/platform-rig": "~0.6.0",
|
||||
@@ -35,7 +36,10 @@
|
||||
"prettier": "^2.4.1",
|
||||
"@rushstack/heft": "^0.41.1",
|
||||
"typescript": "^4.3.5",
|
||||
"@types/body-parser": "~1.19.2"
|
||||
"@types/body-parser": "~1.19.2",
|
||||
"cross-env": "~7.0.3",
|
||||
"ts-node": "~10.5.0",
|
||||
"@types/compression": "~1.7.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@anticrm/core": "~0.6.11",
|
||||
@@ -50,6 +54,7 @@
|
||||
"@anticrm/attachment": "~0.6.0",
|
||||
"@anticrm/contrib": "~0.6.0",
|
||||
"minio": "^7.0.19",
|
||||
"body-parser": "~1.19.1"
|
||||
"body-parser": "~1.19.1",
|
||||
"compression": "~1.7.4"
|
||||
}
|
||||
}
|
||||
|
||||
+15
-3
@@ -19,6 +19,8 @@ import { Account, Doc, Ref, Space } from '@anticrm/core'
|
||||
import { createElasticAdapter } from '@anticrm/elastic'
|
||||
import type { IndexedDoc } from '@anticrm/server-core'
|
||||
import { decodeToken } from '@anticrm/server-token'
|
||||
import bp from 'body-parser'
|
||||
import compression from 'compression'
|
||||
import cors from 'cors'
|
||||
import express from 'express'
|
||||
import fileUpload, { UploadedFile } from 'express-fileupload'
|
||||
@@ -26,7 +28,6 @@ import https from 'https'
|
||||
import { Client, ItemBucketMetadata } from 'minio'
|
||||
import { join, resolve } from 'path'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import bp from 'body-parser'
|
||||
|
||||
async function minioUpload (minio: Client, workspace: string, file: UploadedFile): Promise<string> {
|
||||
const id = uuid()
|
||||
@@ -47,6 +48,17 @@ async function minioUpload (minio: Client, workspace: string, file: UploadedFile
|
||||
export function start (config: { transactorEndpoint: string, elasticUrl: string, minio: Client, accountsUrl: string, uploadUrl: string, modelVersion: string }, port: number): () => void {
|
||||
const app = express()
|
||||
|
||||
app.use(compression({
|
||||
filter: (req, res) => {
|
||||
if (req.headers['x-no-compression'] != null) {
|
||||
// don't compress responses with this request header
|
||||
return false
|
||||
}
|
||||
|
||||
// fallback to standard filter function
|
||||
return compression.filter(req, res)
|
||||
}
|
||||
}))
|
||||
app.use(cors())
|
||||
app.use(fileUpload())
|
||||
app.use(bp.json())
|
||||
@@ -65,9 +77,9 @@ export function start (config: { transactorEndpoint: string, elasticUrl: string,
|
||||
)
|
||||
})
|
||||
|
||||
const dist = resolve(__dirname, 'dist')
|
||||
const dist = resolve(process.env.PUBLIC_DIR ?? __dirname, 'dist')
|
||||
console.log('serving static files from', dist)
|
||||
app.use(express.static(dist, { maxAge: '10m' }))
|
||||
app.use(express.static(dist, { maxAge: '168h' }))
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
app.get('/files', async (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user