-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
80 lines (64 loc) · 2.75 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import (
"runtime"
"github.com/gin-contrib/gzip"
"github.com/gin-gonic/gin"
messageConfig "arkavidia-backend-8.0/competition/config/message"
"arkavidia-backend-8.0/competition/middlewares"
"arkavidia-backend-8.0/competition/routes"
"arkavidia-backend-8.0/competition/utils/mail"
)
// TODO: Gunakan gzip untuk mengkompresi size HTTP Response
// REFERENCE: https://dasarpemrogramangolang.novalagung.com/C-http-gzip-compression.html
// ASSIGNED TO: @rayhankinan
// STATUS: DONE
// TODO: Tambahkan secure middleware untuk menambah security
// REFERENCE: https://dasarpemrogramangolang.novalagung.com/C-secure-middleware.html
// REFERENCE: https://dasarpemrogramangolang.novalagung.com/C-https-tls.html
// NOTES DARI GARE: Pake openssl aja buat generate certificate
// ASSIGNED TO: @confusionhill
// STATUS: IN PROGRESS
// TODO: Tambahkan route render photo dan submission untuk menghindari akses ke google cloud storage secara langsung
// REFERENCE: https://zetcode.com/golang/http-serve-image/
// REFERENCE: https://stackoverflow.com/questions/26744814/serve-image-in-go-that-was-just-created
// REFERENCE: https://freshman.tech/snippets/go/file-content-type/
// REFERENCE: https://stackoverflow.com/questions/51209439/mime-type-checking-of-files-uploaded-golang
// ASSIGNED TO: @patrickamadeus
// STATUS: IN PROGRESS
// TODO: Gunakan GormValuerInterface untuk mengautomatisasi enkripsi bcrypt password
// REFERENCE: https://gorm.io/docs/data_types.html#GormValuerInterface
// ASSIGNED TO: @graceclaudia19
// STATUS: DONE
// TODO: Tambahkan hash pada semua ID di model untuk mencegah terjadinya IDOR
// REFERENCE: https://www.securecoding.com/blog/how-to-prevent-idor-attacks/
// ASSIGNED TO: @akbarmridho
// STATUS: IN PROGRESS
// TODO: Gunakan syntax iota untuk membuat tipe enum untuk memperkecil size penyimpanan pada basis data (string menjadi integer)
// REFERENCE: https://levelup.gitconnected.com/implementing-enums-in-golang-9537c433d6e2
// ASSIGNED TO: @rayhankinan
// STATUS: IN PROGRESS
// TODO: Tambahkan error handling untuk sinkronisasi seluruh error [IN PROGRESS]
// REFERENCE: https://dasarpemrogramangolang.novalagung.com/C-http-error-handling.html
// ASSIGNED TO: @rayhankinan
// STATUS: IN PROGRESS
func main() {
// Configure runtime
runtime.GOMAXPROCS(runtime.NumCPU())
// Gin Framework
engine := gin.Default()
// Middlewares
engine.Use(middlewares.CORSMiddleware())
engine.Use(gzip.Gzip(gzip.DefaultCompression))
// Routes
routes.AdminRoute(engine)
routes.TeamRoute(engine)
routes.ParticipantRoute(engine)
routes.SubmissionRoute(engine)
routes.PhotoRoute(engine)
routes.NotFoundRoute(engine)
// Goroutine Worker
configMessage := messageConfig.Config.GetMetadata()
go mail.Broker.RunMailWorker(configMessage.WorkerSize)
// Run App
engine.Run()
}