Skip to content

Commit 563e1c3

Browse files
committed
✔ Huft ~
1 parent a1af0c8 commit 563e1c3

File tree

4 files changed

+109
-8
lines changed

4 files changed

+109
-8
lines changed

dist/main-site/browser/ngsw.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"configVersion": 1,
3-
"timestamp": 1745719985575,
3+
"timestamp": 1745734953937,
44
"index": "/index.html",
55
"assetGroups": [
66
{

dist/main-site/server/main.js

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

projects/main-site/src/api/app.module.ts

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { DoramaController } from './controllers/dorama.controller';
4040
import { DoramaBerkasController } from './controllers/dorama-/dorama-berkas.controller';
4141
import { DoramaFansubController } from './controllers/dorama-/dorama-fansub.controller';
4242
import { DoramaSeasonalController } from './controllers/dorama-/dorama-seasonal.controller';
43+
import { FanshareController } from './controllers/fanshare.controller';
4344
import { FansubController } from './controllers/fansub.controller';
4445
import { FansubAllController } from './controllers/fansub-/fansub-all.controller';
4546
import { FansubAnimeController } from './controllers/fansub-/fansub-anime.controller';
@@ -195,6 +196,7 @@ import { UserPremiumService } from './repository/user-premium.service';
195196
DoramaBerkasController,
196197
DoramaFansubController,
197198
DoramaSeasonalController,
199+
FanshareController,
198200
FansubController,
199201
FansubAllController,
200202
FansubAnimeController,
@@ -339,7 +341,8 @@ export class AppModule {
339341
{ path: '/api/google-verifikasi', method: RequestMethod.GET },
340342
{ path: '/api/line-verifikasi', method: RequestMethod.GET },
341343
{ path: '/api/aktivasi', method: RequestMethod.GET },
342-
{ path: '/api/verify-sosmed', method: RequestMethod.GET }
344+
{ path: '/api/verify-sosmed', method: RequestMethod.GET },
345+
{ path: '/api/fanshare/u0', method: RequestMethod.ALL }
343346
).forRoutes(
344347
{ path: '*', method: RequestMethod.ALL }
345348
);
@@ -349,7 +352,8 @@ export class AppModule {
349352
{ path: '/api/verify-sosmed', method: RequestMethod.GET },
350353
{ path: '/api/login', method: RequestMethod.POST },
351354
{ path: '/api/register', method: RequestMethod.POST },
352-
{ path: '/api/lost-account-*', method: RequestMethod.POST }
355+
{ path: '/api/lost-account-*', method: RequestMethod.POST },
356+
{ path: '/api/fanshare/u0', method: RequestMethod.ALL }
353357
).forRoutes(
354358
{ path: '*', method: RequestMethod.ALL }
355359
);
@@ -401,17 +405,51 @@ export class AppModule {
401405
mc.apply(
402406
uploadx.upload({
403407
storage: new S3Storage({
404-
path: '/fanshare/u0',
408+
path: '/fanshare',
405409
region: 'auto',
406-
allowMIME: CONSTANTS.fileTypeAttachmentAllowed,
410+
// allowMIME: CONSTANTS.fileTypeAttachmentAllowed,
407411
bucket: environment.cloudflare.r2.bucket,
408412
endpoint: `https://${environment.cloudflare.r2.endpoint}`,
409413
credentials: {
410414
accessKeyId: environment.cloudflare.r2.accessKeyId,
411415
secretAccessKey: environment.cloudflare.r2.secretAccessKey
412416
},
417+
requestChecksumCalculation: 'WHEN_REQUIRED',
418+
responseChecksumValidation: 'WHEN_REQUIRED',
413419
filename: (file: S3File, req) => {
414-
return `u0/${file.name}`;
420+
console.log('filename',);
421+
console.log( file);
422+
const fileName = file.originalName
423+
.replace(CONSTANTS.regexIllegalFileName, '-')
424+
.replace(/\s/g, '_')
425+
.replace(/^[-.~]+|[-.~]+$/g, '')
426+
.substring(0, 255);
427+
return `u0/${new Date().getTime()}_${fileName}`;
428+
},
429+
onCreate: (file: S3File) => {
430+
console.log('onCreate');
431+
console.log(file);
432+
return file;
433+
},
434+
onUpdate: (file: S3File) => {
435+
console.log('onUpdate');
436+
console.log(file);
437+
return file;
438+
},
439+
onComplete: (file: S3File) => {
440+
console.log('onComplete');
441+
console.log(file);
442+
return file;
443+
},
444+
onDelete: (file: S3File) => {
445+
console.log('onDelete');
446+
console.log(file);
447+
return file;
448+
},
449+
onError: (error) => {
450+
console.log('onError');
451+
console.log(error);
452+
return error;
415453
},
416454
forcePathStyle: true,
417455
clientDirectUpload: true,
@@ -420,7 +458,10 @@ export class AppModule {
420458
maxAge: '3d',
421459
purgeInterval: '20min'
422460
},
423-
logLevel: environment.production ? 'error' : 'debug'
461+
metaStorageConfig: {
462+
directory: 'dist/alt-site/temp'
463+
},
464+
logLevel: 'debug'
424465
})
425466
})
426467
).forRoutes(
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { Controller, Get, HttpCode, HttpException, HttpStatus, Post, Req, Res } from '@nestjs/common';
2+
import { ApiExcludeEndpoint } from '@nestjs/swagger';
3+
4+
import { Request, Response } from 'express';
5+
6+
import { FilterApiKeyAccess } from '../decorators/filter-api-key-access.decorator';
7+
8+
@Controller('/fanshare')
9+
export class FanshareController {
10+
11+
constructor() {
12+
//
13+
}
14+
15+
@Get('/:id')
16+
@HttpCode(200)
17+
@ApiExcludeEndpoint()
18+
@FilterApiKeyAccess()
19+
async getById(@Req() req: Request, @Res({ passthrough: true }) res: Response): Promise<any> {
20+
try {
21+
throw new Error('Belum Di Implementasi!');
22+
} catch (error) {
23+
if (error instanceof HttpException) throw error;
24+
throw new HttpException({
25+
info: '🙄 404 - Fanshare API :: Gagal Menarik Data 😪',
26+
result: {
27+
message: 'DDL Tidak Ditemukan!'
28+
}
29+
}, HttpStatus.NOT_FOUND);
30+
}
31+
}
32+
33+
@Post('/')
34+
@HttpCode(201)
35+
@ApiExcludeEndpoint()
36+
@FilterApiKeyAccess()
37+
async uploadLampiran(@Req() req: Request, @Res({ passthrough: true }) res: Response): Promise<any> {
38+
const file = req.body;
39+
console.log('uploadLampiran');
40+
console.log(file);
41+
try {
42+
if (file) {
43+
return {
44+
info: `😅 201 - Fanshare API :: Upload Publik Berhasil 🤣`,
45+
result: req.body
46+
};
47+
}
48+
throw new Error('Data Tidak Lengkap!');
49+
} catch (error) {
50+
if (error instanceof HttpException) throw error;
51+
throw new HttpException({
52+
info: '🙄 400 - Fanshare API :: Gagal Mengunggah Lampiran 😪',
53+
result: {
54+
message: 'Data Tidak Lengkap!'
55+
}
56+
}, HttpStatus.BAD_REQUEST);
57+
}
58+
}
59+
60+
}

0 commit comments

Comments
 (0)