Skip to content

Commit 23eac9e

Browse files
committed
test: url connection after book deploy
1 parent 4a93c96 commit 23eac9e

File tree

7 files changed

+319
-23
lines changed

7 files changed

+319
-23
lines changed

apps/book-server/scripts/createMock.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Seeder {
1010
const exists = await this.mongo.writer.findFirst({})
1111

1212
if (exists) {
13-
throw new Error('Already exists mock data')
13+
return exists
1414
}
1515

1616
return this.mongo.writer.create({

apps/book-server/src/services/BookBuildService/index.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ export class BookBuildService implements Service {
9393

9494
fs.writeFileSync(
9595
`${dest}/next.config.mjs`,
96-
nextConfigTempate({ bucketUrl: this.env.get('bookBucketUrl'), bookId }),
96+
nextConfigTempate({
97+
bucketUrl: this.env.get('bookBucketUrl'),
98+
bookId,
99+
}),
97100
)
98101
fs.writeFileSync(`${dest}/theme.config.tsx`, themeConfigTemplate({ title: book.title }))
99102

apps/book-server/src/services/BookDeployService/index.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ export class BookDeployService implements Service {
7676

7777
try {
7878
await Promise.all(promises)
79+
80+
console.log(`Deployed URL: , ${this.env.get('bookBucketUrl')}/${bookId}/index.html`)
7981
} catch (error) {
8082
console.error(error)
8183
}

apps/book-server/src/templates/nextConfigTemplate.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export const nextConfigTempate = ({ bucketUrl, bookId }: Props) => {
2323
unoptimized: true,
2424
},
2525
assetPrefix: process.env.NODE_ENV === 'production' ? '${bucketUrl}/${bookId}' : undefined,
26+
basePath: '/${bookId}',
27+
trailingSlash: false
2628
}
2729
2830
export default withNextra(nextConfig)

apps/web/next.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ const nextConfig = {
1212
assetPrefix: isProductionContainer
1313
? 'https://assets.velcdn.com'
1414
: isStageContainer
15-
? 'https://assets-stage.velcdn.com/'
16-
: undefined,
15+
? 'https://assets-stage.velcdn.com/'
16+
: undefined,
1717
experimental: {
1818
esmExternals: true, // support esm
1919
taint: true, // for security

packages/library/src/awsS3/AwsS3Service.mts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Bucket,
66
PutObjectCommand,
77
PutObjectCommandInput,
8+
PutObjectCommandOutput,
89
} from '@aws-sdk/client-s3'
910

1011
type Params = {
@@ -30,7 +31,12 @@ export class AwsS3Service implements Service {
3031
return []
3132
}
3233
}
33-
public async uploadFile({ bucketName, key, body, ...args }: UploadFileArgs): Promise<void> {
34+
public async uploadFile({
35+
bucketName,
36+
key,
37+
body,
38+
...args
39+
}: UploadFileArgs): Promise<PutObjectCommandOutput> {
3440
const buckets = await this.getBuckets()
3541
const bucket = buckets.find((bucket) => bucket.Name === bucketName)
3642

@@ -45,8 +51,7 @@ export class AwsS3Service implements Service {
4551
...args,
4652
}
4753
const command = new PutObjectCommand(input)
48-
const response = await this.client.send(command)
49-
console.log(response)
54+
return await this.client.send(command)
5055
}
5156
}
5257

0 commit comments

Comments
 (0)