feat: add modules/storage export and bundle config files
- Add `./modules/storage` package export pointing to `modules.storage.js` - Add `modules/*/config.js` to tsup build entries for server-only configs - Add `@zen/core/modules/storage` to external dependencies in tsup config - Add `src/modules/modules.storage.js` to the second tsup build target - Update storage handler to import via `@zen/core/modules/storage` alias - Rename unused `request` param to `_request` in `handleGetFile`
This commit is contained in:
@@ -133,6 +133,9 @@
|
|||||||
"./modules/actions": {
|
"./modules/actions": {
|
||||||
"import": "./dist/modules/modules.actions.js"
|
"import": "./dist/modules/modules.actions.js"
|
||||||
},
|
},
|
||||||
|
"./modules/storage": {
|
||||||
|
"import": "./dist/modules/modules.storage.js"
|
||||||
|
},
|
||||||
"./modules/posts/crud": {
|
"./modules/posts/crud": {
|
||||||
"import": "./dist/modules/posts/crud.js"
|
"import": "./dist/modules/posts/crud.js"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import { validateSession } from '../../../features/auth/lib/session.js';
|
import { validateSession } from '../../../features/auth/lib/session.js';
|
||||||
import { cookies } from 'next/headers';
|
import { cookies } from 'next/headers';
|
||||||
import { getSessionCookieName } from '../../../shared/lib/appConfig.js';
|
import { getSessionCookieName } from '../../../shared/lib/appConfig.js';
|
||||||
import { getAllStoragePublicPrefixes } from '../../../../modules/modules.storage.js';
|
import { getAllStoragePublicPrefixes } from '@zen/core/modules/storage';
|
||||||
import { getFile } from '@zen/core/storage';
|
import { getFile } from '@zen/core/storage';
|
||||||
|
|
||||||
// Get cookie name from environment or use default
|
// Get cookie name from environment or use default
|
||||||
@@ -18,7 +18,7 @@ const COOKIE_NAME = getSessionCookieName();
|
|||||||
* @param {string} fileKey - The file key/path in storage
|
* @param {string} fileKey - The file key/path in storage
|
||||||
* @returns {Promise<Response|Object>} File response or error object
|
* @returns {Promise<Response|Object>} File response or error object
|
||||||
*/
|
*/
|
||||||
export async function handleGetFile(request, fileKey) {
|
export async function handleGetFile(_request, fileKey) {
|
||||||
try {
|
try {
|
||||||
// Reject any path that contains traversal sequences, empty segments, or
|
// Reject any path that contains traversal sequences, empty segments, or
|
||||||
// absolute path indicators before splitting or passing to the storage backend.
|
// absolute path indicators before splitting or passing to the storage backend.
|
||||||
|
|||||||
+4
-2
@@ -28,10 +28,11 @@ export default defineConfig([
|
|||||||
'src/modules/init.js',
|
'src/modules/init.js',
|
||||||
'src/modules/pages.js',
|
'src/modules/pages.js',
|
||||||
'src/modules/modules.metadata.js',
|
'src/modules/modules.metadata.js',
|
||||||
// Module actions, API and CRUD (bundled to resolve relative imports)
|
// Module actions, API, CRUD and server-only config (bundled to resolve relative imports)
|
||||||
'src/modules/*/actions.js',
|
'src/modules/*/actions.js',
|
||||||
'src/modules/*/api.js',
|
'src/modules/*/api.js',
|
||||||
'src/modules/*/crud.js',
|
'src/modules/*/crud.js',
|
||||||
|
'src/modules/*/config.js',
|
||||||
'src/shared/lib/metadata/index.js',
|
'src/shared/lib/metadata/index.js',
|
||||||
],
|
],
|
||||||
format: ['esm'],
|
format: ['esm'],
|
||||||
@@ -39,7 +40,7 @@ export default defineConfig([
|
|||||||
splitting: false,
|
splitting: false,
|
||||||
sourcemap: false,
|
sourcemap: false,
|
||||||
clean: true,
|
clean: true,
|
||||||
external: ['react', 'react-dom', 'next', 'pg', 'dotenv', 'dotenv/config', 'resend', '@react-email/components', 'node-cron', 'readline', 'crypto', 'url', 'fs', 'path', 'net', 'dns', 'tls', '@zen/core/database', '@zen/core/email', '@zen/core/email/templates', '@zen/core/storage', '@zen/core/toast', '@zen/core/modules/actions', '@aws-sdk/client-s3', '@aws-sdk/s3-request-presigner'],
|
external: ['react', 'react-dom', 'next', 'pg', 'dotenv', 'dotenv/config', 'resend', '@react-email/components', 'node-cron', 'readline', 'crypto', 'url', 'fs', 'path', 'net', 'dns', 'tls', '@zen/core/database', '@zen/core/email', '@zen/core/email/templates', '@zen/core/storage', '@zen/core/toast', '@zen/core/modules/actions', '@zen/core/modules/storage', '@aws-sdk/client-s3', '@aws-sdk/s3-request-presigner'],
|
||||||
noExternal: [],
|
noExternal: [],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
banner: {
|
banner: {
|
||||||
@@ -63,6 +64,7 @@ export default defineConfig([
|
|||||||
'src/features/admin/navigation.server.js',
|
'src/features/admin/navigation.server.js',
|
||||||
'src/modules/page.js',
|
'src/modules/page.js',
|
||||||
'src/modules/modules.actions.js',
|
'src/modules/modules.actions.js',
|
||||||
|
'src/modules/modules.storage.js',
|
||||||
],
|
],
|
||||||
format: ['esm'],
|
format: ['esm'],
|
||||||
dts: false,
|
dts: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user