Skip to content

Commit 6cdac5f

Browse files
committed
adjust: upload image of category sapawarga
1 parent 9a51769 commit 6cdac5f

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

src/database/constant/image.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const categories = ['logo', 'aduan']
1+
export const categories = ['logo', 'sapawarga']

src/modules/images/images.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import Handler from './delivery/http/handler'
55
import Repository from './repository/mongo/repository'
66
import { Config } from '../../config/config.interface'
77
import S3 from '../../external/s3'
8-
import Jwt from '../../pkg/jwt'
9-
import { VerifyAuth } from '../../transport/http/middleware/verifyAuth'
108

119
class Images {
1210
constructor(
@@ -37,14 +35,7 @@ class Images {
3735
private httpPrivate(handler: Handler) {
3836
const Router = this.http.Router()
3937

40-
const auth = new Jwt(this.config.jwt.access_key)
41-
42-
Router.post(
43-
'/',
44-
VerifyAuth(auth),
45-
this.http.Upload('file'),
46-
handler.Store()
47-
)
38+
Router.post('/', this.http.Upload('file'), handler.Store())
4839

4940
this.http.SetRouter('/v1/images', Router)
5041
}

src/modules/images/usecase/usecase.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ class Usecase {
2020
}
2121

2222
public async Store(body: Store) {
23-
const newPath = CustomPathFile(getSlug(body.category), body.file)
24-
body.title = body.title ?? body.file.originalname.replace(RegexExtensionImage, '')
23+
const category = getSlug(body.category)
24+
const newPath = CustomPathFile(category, body.file)
25+
body.title =
26+
body.title ??
27+
body.file.originalname.replace(RegexExtensionImage, '')
2528
body.tags.push(body.title, body.category)
2629
const source = readFileSync(body.file.path)
2730

0 commit comments

Comments
 (0)