diff --git a/.github/workflows/release-executables.yml b/.github/workflows/release-executables.yml index c05211abe8..02e26036ee 100644 --- a/.github/workflows/release-executables.yml +++ b/.github/workflows/release-executables.yml @@ -87,7 +87,7 @@ jobs: ./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=arm64 --target_libc=musl # clean up code to optimize size - npx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**,sqlite3/**" --run + npx modclean --patterns="default:*" --ignore="nc-lib-gui/**,nocodb/**,dayjs/**,express-status-monitor/**,sqlite3/**" --run # build executables npm run build diff --git a/.github/workflows/release-timely-executables.yml b/.github/workflows/release-timely-executables.yml index b8da4543e3..ab7706709c 100644 --- a/.github/workflows/release-timely-executables.yml +++ b/.github/workflows/release-timely-executables.yml @@ -103,7 +103,7 @@ jobs: # clean up code to optimize size - npx modclean --patterns="default:*" --ignore="nc-lib-gui-daily/**,dayjs/**,express-status-monitor/**,sqlite3/**" --run + npx modclean --patterns="default:*" --ignore="nc-lib-gui-daily/**,nocodb-daily/**,dayjs/**,express-status-monitor/**,sqlite3/**" --run # build executables npm run build diff --git a/packages/nocodb/Dockerfile b/packages/nocodb/Dockerfile index 43b257df5c..1d82b0f199 100644 --- a/packages/nocodb/Dockerfile +++ b/packages/nocodb/Dockerfile @@ -31,9 +31,9 @@ COPY ./package*.json ./ COPY ./docker/main.js ./docker/main.js #COPY ./docker/start.sh /usr/src/appEntry/start.sh COPY ./docker/start-litestream.sh /usr/src/appEntry/start.sh -COPY ./src/lib/public/css/*.css /usr/src/appEntry/public/css/ -COPY ./src/lib/public/js/*.js /usr/src/appEntry/public/js/ -COPY ./src/lib/public/favicon.ico /usr/src/appEntry/public/ +COPY ./src/lib/public/css/*.css ./docker/public/css/ +COPY ./src/lib/public/js/*.js ./docker/public/js/ +COPY ./src/lib/public/favicon.ico ./docker/public/ # install production dependencies, # reduce node_module size with modclean & removing sqlite deps, diff --git a/packages/nocodb/docker/webpack.config.js b/packages/nocodb/docker/webpack.config.js index 9513b6e73a..87675b32be 100644 --- a/packages/nocodb/docker/webpack.config.js +++ b/packages/nocodb/docker/webpack.config.js @@ -56,4 +56,7 @@ module.exports = { // }) ], target: 'node', -}; \ No newline at end of file + node: { + __dirname: false, + }, +}; diff --git a/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts b/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts index e3a340268b..4ef4b7ce5e 100644 --- a/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts +++ b/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts @@ -10,11 +10,16 @@ import ncMetaAclMw from '../../helpers/ncMetaAclMw'; import { getViewAndModelFromRequestByAliasOrId } from './helpers'; import apiMetrics from '../../helpers/apiMetrics'; import getAst from '../../../db/sql-data-mapper/lib/sql/helpers/getAst'; +import { parseHrtimeToSeconds } from '../helpers'; // todo: Handle the error case where view doesnt belong to model async function dataList(req: Request, res: Response) { + const startTime = process.hrtime(); const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); - res.json(await getDataList(model, view, req)); + const responseData = await getDataList(model, view, req); + const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(startTime)); + res.setHeader('xc-db-response', elapsedSeconds); + res.json(responseData); } async function dataFindOne(req: Request, res: Response) { @@ -226,8 +231,12 @@ async function dataExist(req: Request, res: Response) { // todo: Handle the error case where view doesnt belong to model async function groupedDataList(req: Request, res: Response) { + const startTime = process.hrtime(); const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); - res.json(await getGroupedDataList(model, view, req)); + const groupedData = await getGroupedDataList(model, view, req); + const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(startTime)); + res.setHeader('xc-db-response', elapsedSeconds); + res.json(groupedData); } async function getGroupedDataList(model, view: View, req) { diff --git a/packages/nocodb/src/lib/meta/api/helpers/apiHelpers.ts b/packages/nocodb/src/lib/meta/api/helpers/apiHelpers.ts new file mode 100644 index 0000000000..4ffeeb82b6 --- /dev/null +++ b/packages/nocodb/src/lib/meta/api/helpers/apiHelpers.ts @@ -0,0 +1,4 @@ +export function parseHrtimeToSeconds(hrtime) { + const seconds = (hrtime[0] + hrtime[1] / 1e6).toFixed(3); + return seconds; +} diff --git a/packages/nocodb/src/lib/meta/api/helpers/index.ts b/packages/nocodb/src/lib/meta/api/helpers/index.ts index 1b1e81ecfa..1fd8d4367b 100644 --- a/packages/nocodb/src/lib/meta/api/helpers/index.ts +++ b/packages/nocodb/src/lib/meta/api/helpers/index.ts @@ -1,4 +1,5 @@ import { populateMeta } from './populateMeta'; export * from './columnHelpers'; +export * from './apiHelpers'; export { populateMeta }; diff --git a/packages/nocodb/webpack.config.js b/packages/nocodb/webpack.config.js index 9c189cc430..c5c927d79f 100644 --- a/packages/nocodb/webpack.config.js +++ b/packages/nocodb/webpack.config.js @@ -40,7 +40,8 @@ module.exports = { globalObject: "typeof self !== 'undefined' ? self : this" }, node: { - fs: 'empty' + fs: 'empty', + __dirname: false, }, plugins: [ new webpack.EnvironmentPlugin([ @@ -58,5 +59,5 @@ module.exports = { // }, []), ], - target: 'node', -}; \ No newline at end of file + target: 'node' +};