14 changed files with 54 additions and 36 deletions
+3 -1
View File
@@ -1,4 +1,6 @@
FROM golang:1.24 AS build FROM golang:1.20-alpine AS build
RUN apk --no-cache add tzdata
WORKDIR /src WORKDIR /src
COPY . . COPY . .
+6
View File
@@ -148,6 +148,12 @@ make run
This command will compile and execute your Go application. This command will compile and execute your Go application.
Or you can execute the compiled binary at `bin/legalgo` by:
```bash
./bin/legalgo
```
--- ---
**Note:** Ensure that your `Makefile` is correctly set up to handle these commands. If not, you may need to create **Note:** Ensure that your `Makefile` is correctly set up to handle these commands. If not, you may need to create
+1 -1
View File
@@ -10,7 +10,7 @@ import (
) )
const ( const (
YAML_PATH = "env/%s" YAML_PATH = "%s"
ENV_MODE = "ENV_MODE" ENV_MODE = "ENV_MODE"
DEFAULT_ENV_MODE = "development" DEFAULT_ENV_MODE = "development"
) )
+2 -1
View File
@@ -6,7 +6,8 @@ import (
type Staff struct { type Staff struct {
ID string `gorm:"primaryKey" json:"id"` ID string `gorm:"primaryKey" json:"id"`
Username string `gorm:"default:null;unique" json:"username"` Name string `gorm:"default:null;unique" json:"name"`
ProfilePicture string `gorm:"default:null" json:"profile_picture"`
Email string `gorm:"unique;not null" json:"email"` Email string `gorm:"unique;not null" json:"email"`
Password string `gorm:"not null" json:"password"` Password string `gorm:"not null" json:"password"`
CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"` CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
+1 -1
View File
@@ -49,7 +49,7 @@ func UpdateStaff(
ID: id, ID: id,
Email: spec.Email, Email: spec.Email,
Password: spec.Password, Password: spec.Password,
Username: spec.Username, Name: spec.Name,
} }
if err := authSvc.UpdateStaff(staff); err != nil { if err := authSvc.UpdateStaff(staff); err != nil {
+2 -1
View File
@@ -19,7 +19,8 @@ type LoginRepoResponse struct {
type StaffProfile struct { type StaffProfile struct {
ID string `json:"id"` ID string `json:"id"`
Email string `json:"email"` Email string `json:"email"`
Username string `json:"username"` Name string `json:"name"`
ProfilePicture string `json:"profile_picture"`
} }
type UserProfile struct { type UserProfile struct {
+5 -3
View File
@@ -18,18 +18,20 @@ type User struct {
type RegisterStaffReq struct { type RegisterStaffReq struct {
Email string `json:"email" validate:"required"` Email string `json:"email" validate:"required"`
Password string `json:"password" validate:"required"` Password string `json:"password" validate:"required"`
Username string `json:"username" validate:"required"` Name string `json:"name" validate:"required"`
ProfilePicture string `json:"profile_picture"`
} }
type UpdateStaffReq struct { type UpdateStaffReq struct {
Email string `json:"email"` Email string `json:"email"`
Password string `json:"password"` Password string `json:"password"`
Username string `json:"username"` Name string `json:"name"`
} }
type Staff struct { type Staff struct {
ID string `json:"id"` ID string `json:"id"`
Email string `json:"email"` Email string `json:"email"`
Password string `json:"password"` Password string `json:"password"`
Username string `json:"username"` Name string `json:"name"`
ProfilePicture string `json:"profile_picture"`
} }
+2 -1
View File
@@ -10,8 +10,9 @@ func (as *AuthSvc) GetStaffProfile(email string) (*authdomain.StaffProfile, erro
profile := &authdomain.StaffProfile{ profile := &authdomain.StaffProfile{
ID: staff.ID, ID: staff.ID,
Username: staff.Username, Name: staff.Name,
Email: staff.Email, Email: staff.Email,
ProfilePicture: staff.ProfilePicture,
} }
return profile, nil return profile, nil
+2 -1
View File
@@ -23,7 +23,8 @@ func (a *AuthSvc) RegisterStaff(spec authdomain.RegisterStaffReq) (string, error
ID: uuid.NewString(), ID: uuid.NewString(),
Email: spec.Email, Email: spec.Email,
Password: hashedPwd, Password: hashedPwd,
Username: spec.Username, Name: spec.Name,
ProfilePicture: spec.ProfilePicture,
} }
_, err = a.staffRepo.Create(&staff) _, err = a.staffRepo.Create(&staff)
+1 -1
View File
@@ -20,7 +20,7 @@ spec:
ports: ports:
- containerPort: 3000 - containerPort: 3000
volumeMounts: volumeMounts:
- mountPath: "/env" - mountPath: "/"
name: legalgonews-backend-secret name: legalgonews-backend-secret
readOnly: true readOnly: true
volumes: volumes:
+1 -1
View File
@@ -18,7 +18,7 @@ spec:
service: service:
name: legalgonews-backend name: legalgonews-backend
port: port:
number: 3000 number: 3300
tls: tls:
- hosts: - hosts:
- "legalgonews-be.app-dev.altru.id" - "legalgonews-be.app-dev.altru.id"
+2 -2
View File
@@ -7,9 +7,9 @@ metadata:
run: legalgonews-backend run: legalgonews-backend
spec: spec:
ports: ports:
- port: 3000 - port: 3300
protocol: TCP protocol: TCP
targetPort: 3000 targetPort: 3300
selector: selector:
app: legalgonews-backend app: legalgonews-backend
type: ClusterIP type: ClusterIP
+7 -3
View File
@@ -25,7 +25,9 @@ paths:
type: string type: string
email: email:
type: string type: string
username: name:
type: string
profile_picture:
type: string type: string
"400": "400":
description: Bad request description: Bad request
@@ -108,12 +110,14 @@ paths:
format: email format: email
password: password:
type: string type: string
username: name:
type: string
profile_picture:
type: string type: string
required: required:
- email - email
- password - password
- username - name
responses: responses:
"201": "201":
description: Staff member created description: Staff member created