Skip to content

Commit 87ef4ba

Browse files
committed
chore: wip
chore: wip chore: wip
1 parent 29f2423 commit 87ef4ba

File tree

8 files changed

+28
-22
lines changed

8 files changed

+28
-22
lines changed

storage/framework/.biomelintrc-auto-import.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,4 +349,4 @@
349349
"whenever"
350350
]
351351
}
352-
}
352+
}

storage/framework/core/cloud/src/cloud/cdn.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,15 @@ export class CdnStack {
260260
protocolPolicy: cloudfront.OriginProtocolPolicy.HTTPS_ONLY,
261261
})
262262

263+
const apiCachePolicy = this.setApiCachePolicy(scope)
264+
263265
return {
264266
'/api': {
265267
origin,
266268
compress: true,
267269
allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
268270
cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD_OPTIONS,
269-
cachePolicy: this.setApiCachePolicy(scope),
271+
cachePolicy: apiCachePolicy,
270272
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
271273
realtimeLogConfig: this.realtimeLogConfig,
272274
},
@@ -276,7 +278,7 @@ export class CdnStack {
276278
compress: true,
277279
allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
278280
cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD_OPTIONS,
279-
cachePolicy: this.apiCachePolicy,
281+
cachePolicy: apiCachePolicy,
280282
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
281283
realtimeLogConfig: this.realtimeLogConfig,
282284
},
@@ -514,7 +516,10 @@ export class CdnStack {
514516
]
515517
keysToRemove.forEach((key) => delete env[key as EnvKey])
516518

517-
behaviorOptions = this.apiBehaviorOptions(scope, props)
519+
behaviorOptions = {
520+
...this.apiBehaviorOptions(scope, props),
521+
...behaviorOptions,
522+
}
518523
}
519524

520525
// if docMode is used, we don't need to add a behavior for the docs
@@ -549,15 +554,16 @@ export class CdnStack {
549554

550555
this.apiCachePolicy = new cloudfront.CachePolicy(scope, 'ApiCachePolicy', {
551556
comment: 'Stacks API Cache Policy',
552-
cachePolicyName: `${this.props.slug}-${this.props.appEnv}-api-cache-policy`,
557+
cachePolicyName: `${this.props.slug}-${this.props.appEnv}-api-cache-policy-${this.props.timestamp}`,
553558
defaultTtl: Duration.seconds(0),
554559
minTtl: Duration.seconds(0),
555-
maxTtl: Duration.seconds(0),
560+
maxTtl: Duration.seconds(1), // Changed from 0 to 1 second
556561

557-
// minTtl: config.cloud.cdn?.minTtl ? Duration.seconds(config.cloud.cdn.minTtl) : undefined,
558562
cookieBehavior: cloudfront.CacheCookieBehavior.all(),
559563
headerBehavior: cloudfront.CacheHeaderBehavior.allowList('Authorization', 'Content-Type'),
560564
queryStringBehavior: cloudfront.CacheQueryStringBehavior.all(),
565+
enableAcceptEncodingGzip: true, // Added this line
566+
enableAcceptEncodingBrotli: true, // Added this line
561567
})
562568

563569
return this.apiCachePolicy

storage/framework/core/vite-plugin/src/router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function router(options?: RouterOptions) {
1919

2020
if (options?.type === 'views') {
2121
return VueRouter({
22-
exclude: ['/dashboard/**', '/errors/**', '/system-tray/**'],
22+
exclude: ['/dashboard/**', '/errors/**', '/system-tray/**', '/docs/**', '/api/**'], // these are provided by the framework, and that's why they cannot be reused
2323
...opts,
2424
})
2525
}

storage/framework/server/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ cdk.out
1414
chunk-*
1515
*.node
1616
index.js*
17-
storage-tmp
17+
storage
1818

storage/framework/server/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ COPY --from=builder /usr/src/tsconfig.json ./tsconfig.json
3333
USER root
3434
RUN mkdir -p ./storage
3535

36-
COPY --chown=bun:bun ./storage-tmp ./storage
36+
COPY --chown=bun:bun ./storage ./storage
3737

3838
# Add storage volume for logs and other files
3939
VOLUME ["/usr/src/storage"]

storage/framework/server/build.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async function main() {
2323
log.info('Stopped stacks-server container')
2424
}
2525

26-
log.info('Deleting old files...')
26+
log.info('Cleanup of previous build files...')
2727
log.info(` ${path.userServerPath('app')}`, { styled: false })
2828
await deleteFolder(path.userServerPath('app'))
2929
log.info(` ${path.userServerPath('config')}`, { styled: false })
@@ -33,8 +33,9 @@ async function main() {
3333
log.info(` ${path.userServerPath('docs')}`, { styled: false })
3434
await deleteFolder(path.userServerPath('docs'))
3535
log.info(` ${path.userServerPath('storage')}`, { styled: false })
36-
await deleteFolder(path.userServerPath('storage'))
37-
log.success('Deleted old files')
36+
// await deleteFolder(path.userServerPath('storage'))
37+
await Bun.$`rm -rf ${path.userServerPath('storage')}`.text()
38+
log.success('Cleaned up previous build files')
3839

3940
log.info('Building...')
4041
const result = await build({
@@ -49,7 +50,7 @@ async function main() {
4950
if (result.success) {
5051
log.success('Server built')
5152
} else {
52-
log.error('Build failed')
53+
log.error('Server Build failed')
5354
process.exit(1)
5455
}
5556

@@ -130,13 +131,13 @@ async function main() {
130131

131132
try {
132133
Bun.$.cwd(path.userServerPath())
133-
await Bun.$`rm -rf ./storage-tmp/framework/**/dist ./storage-tmp/**/node_modules ./storage-tmp/framework/**/src ./storage-tmp/framework/core/**/tests ./storage-tmp/**/*.DS_Store ./storage-tmp/**/*.lockb`.text()
134+
await Bun.$`rm -rf ./storage/framework/**/dist ./storage/**/node_modules ./storage/framework/**/src ./storage/framework/core/**/tests ./storage/**/*.DS_Store ./storage/**/*.lockb`
135+
.nothrow()
136+
.text()
134137
log.success('Optimized Docker Image size')
135138
} catch (err: any) {
136139
log.error('Optimization failed')
137-
console.log(`Failed with code ${err.exitCode}`)
138-
console.log(err.stdout.toString())
139-
console.log(err.stderr.toString())
140+
log.error(err)
140141
process.exit(1)
141142
}
142143

@@ -148,7 +149,6 @@ async function main() {
148149
})
149150

150151
if (cloud.api?.deploy) await buildDockerImage()
151-
await Bun.$`rm -rf ${path.userServerPath('storage-tmp')}`.text()
152152
}
153153

154154
main()

storage/framework/server/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
"contributors": ["Chris Breuer <chris@stacksjs.org>"],
3939
"files": ["README.md", "dist", "src"],
4040
"scripts": {
41-
"dev": "./dev local",
42-
"dev:cloud": "docker run -d -p 3000:3000 --name stacks-server --restart unless-stopped stacks",
41+
"dev": "docker run -d -p 3000:3000 --name stacks-server --restart unless-stopped stacks",
42+
"dev:local": "./dev local",
4343
"build": "bun build.ts"
4444
},
4545
"devDependencies": {

storage/framework/server/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export async function buildDockerImage() {
7171
log.success('Copied docs files')
7272

7373
log.info('Copying storage files...')
74-
await cleanCopy(projectPath('storage'), frameworkPath('server/storage-tmp'))
74+
await cleanCopy(projectPath('storage'), frameworkPath('server/storage'))
7575
log.success('Copied storage files')
7676

7777
log.info('Copying .env file...')

0 commit comments

Comments
 (0)