Skip to content

Commit f9358c7

Browse files
authored
Merge pull request #13 from shion1305/issue/8-rc0
フロントエンド開発用設定の追加 / #8 の実装途中
2 parents e6c7c91 + c5b9260 commit f9358c7

40 files changed

+491
-142
lines changed

.github/workflows/go test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
- name: Checkout code
1212
uses: actions/checkout@v2
1313
- run: |
14-
echo "ENV_LOCATION=$GITHUB_WORKSPACE/pkg/setting/files/setting.develop.yaml"
15-
echo "ENV_LOCATION=$GITHUB_WORKSPACE/pkg/setting/files/setting.develop.yaml" >> $GITHUB_ENV
14+
echo "ENV_LOCATION=$GITHUB_WORKSPACE/pkg/setting/files/setting.testing.yaml"
15+
echo "ENV_LOCATION=$GITHUB_WORKSPACE/pkg/setting/files/setting.testing.yaml" >> $GITHUB_ENV
1616
- name: 'Set up Cloud SDK'
1717
uses: 'google-github-actions/setup-gcloud@v1'
1818
- name: 'Install gcloud required components'

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM gcr.io/google.com/cloudsdktool/google-cloud-cli:alpine
2-
RUN apk add --update --no-cache vim git make musl-dev go curl openjdk11-jre-headless
2+
RUN apk add --update --no-cache vim git make musl-dev go~=1.17.10 curl openjdk11-jre-headless
33
RUN ["gcloud", "components", "install", "beta", "cloud-firestore-emulator", "--quiet"]
44
# RUN firestore emulator
55
# WAIT 10 seconds for the emulator to start
@@ -9,6 +9,6 @@ COPY . .
99

1010
#CMD ["gcloud", "beta", "emulators" ,"firestore","start","--quiet","--host-port","localhost:8020"]
1111
CMD /bin/sh -c "./run-test.sh"
12-
COPY ./pkg/setting/files/setting.develop.yaml /setting.yaml
12+
COPY pkg/setting/files/setting.testing.yaml /setting.yaml
1313
ENV ENV_LOCATION /setting.yaml
1414
ENV FIRESTORE_EMULATOR_HOST localhost:8020

pkg/identity/id.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package identity
2+
3+
import (
4+
"strconv"
5+
"ynufes-mypage-backend/pkg/snowflake"
6+
"ynufes-mypage-backend/svc/pkg/domain/model/util"
7+
)
8+
9+
type (
10+
ID snowflake.Snowflake
11+
IDManager struct {
12+
}
13+
)
14+
15+
func NewIDManager() IDManager {
16+
return IDManager{}
17+
}
18+
19+
func (IDManager) IssueID() util.ID {
20+
return ID(snowflake.NewSnowflake())
21+
}
22+
23+
func (IDManager) ImportID(id string) (util.ID, error) {
24+
result, err := strconv.ParseInt(id, 36, 64)
25+
if err != nil {
26+
return ID(0), err
27+
}
28+
return ID(result), nil
29+
}
30+
31+
func NewID(id int64) ID {
32+
return ID(id)
33+
}
34+
35+
func (i ID) ExportID() string {
36+
return strconv.FormatInt(int64(i), 36)
37+
}
38+
39+
func (i ID) HasValue() bool {
40+
return i != 0
41+
}

pkg/setting/application.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,21 @@ type (
66
Admin Admin `yaml:"admin"`
77
}
88
Server struct {
9-
Domain string `yaml:"domain"`
9+
OnProduction bool `yaml:"on_production"`
10+
Frontend Frontend `yaml:"frontend"`
11+
Backend Backend `yaml:"backend"`
1012
}
1113
Admin struct {
1214
JwtSecret string `yaml:"jwt_secret"`
1315
}
16+
Frontend struct {
17+
Protocol string `yaml:"protocol"`
18+
Domain string `yaml:"domain"`
19+
Port string `yaml:"port"`
20+
}
21+
Backend struct {
22+
Protocol string `yaml:"protocol"`
23+
Domain string `yaml:"domain"`
24+
Port string `yaml:"port"`
25+
}
1426
)

pkg/setting/files/setting.develop.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

pkg/setting/files/setting.template.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
application:
22
server:
3-
domain: "ynufes-mypage.shion.pro"
3+
on_production: true
4+
# IF FRONTEND AND BACKEND SERVICE ARE ON THE SAME SERVER, MAKE THIS TRUE
5+
frontend:
6+
protocol: "https://"
7+
domain: "ynufes-mypage.shion.pro"
8+
port: ""
9+
backend:
10+
protocol: "https://"
11+
domain: "ynufes-mypage.shion.pro"
12+
port: ":1306"
13+
# CONCATING PROTOCOL, DOMAIN, AND PORT TOGETHER SHOULD GIVE THE FULL URL
414
infrastructure:
515
firestore:
616
project_id: "ynufes-mypage"
@@ -14,3 +24,6 @@ third_party:
1424
# CIPHER KEY HAS TO BE 16, 24, OR 32 BYTES LONG
1525
enable_line_auth: true
1626
service:
27+
authentication:
28+
secure_cookie: true
29+
# YOU CAN DISABLE SECURE COOKIE FOR TESTING PURPOSES
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This file is used for GitHub Action CI
2+
application:
3+
server:
4+
on_production: true
5+
# ASSUME IF FRONTEND AND BACKEND SERVICE ARE ON THE SAME SERVER
6+
frontend:
7+
protocol: "https://"
8+
domain: "ynufes-mypage.shion.pro"
9+
port: ""
10+
backend:
11+
protocol: "https://"
12+
domain: "ynufes-mypage.shion.pro"
13+
port: ""
14+
# CONCATING PROTOCOL, DOMAIN, AND PORT TOGETHER SHOULD GIVE THE FULL URL
15+
infrastructure:
16+
firestore:
17+
project_id: "ynufes-mypage"
18+
json_credential_file: "TESTING"
19+
third_party:
20+
line_login:
21+
client_id: "LINE_AUTH_CLIENT_ID"
22+
client_secret: "LINE_AUTH_CLIENT_SECRET"
23+
callback_uri: "LINE_AUTH_CALLBACK_URI"
24+
cipher_key: "LINE_AUTH_CIPHER_KEY_TEST_TEST12"
25+
# CIPHER KEY HAS TO BE 16, 24, OR 32 BYTES LONG
26+
enable_line_auth: false
27+
# DISABLE LINE AUTH ON TESTING
28+
service:
29+
authentication:
30+
secure_cookie: false
31+
# DISABLE SECURE COOKIE ON TESTING

pkg/setting/service.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@ package setting
22

33
type (
44
Service struct {
5+
Authentication Authentication `yaml:"authentication"`
6+
}
7+
Authentication struct {
8+
SecureCookie bool `yaml:"secure_cookie"`
59
}
610
)

pkg/testutil/sample_users.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package testutil
22

3-
import "ynufes-mypage-backend/svc/pkg/domain/model/user"
3+
import (
4+
"ynufes-mypage-backend/pkg/identity"
5+
"ynufes-mypage-backend/svc/pkg/domain/model/user"
6+
)
47

58
func Users() []user.User {
69
return []user.User{
710
{
8-
ID: 1234,
11+
ID: user.ID(identity.NewID(1234)),
912
Status: user.StatusNew,
1013
Detail: user.Detail{
1114
Name: user.Name{
@@ -24,12 +27,9 @@ func Users() []user.User {
2427
EncryptedAccessToken: "EncryptedAccessToken",
2528
EncryptedRefreshToken: "EncryptedRefreshToken",
2629
},
27-
Dashboard: user.Dashboard{
28-
Grants: []string{"grant1", "grant2"},
29-
},
3030
},
3131
{
32-
ID: 12344,
32+
ID: user.ID(identity.NewID(12344)),
3333
Status: user.StatusRegistered,
3434
Detail: user.Detail{
3535
Name: user.Name{
@@ -48,9 +48,6 @@ func Users() []user.User {
4848
EncryptedAccessToken: "EncryptedAccessToken",
4949
EncryptedRefreshToken: "EncryptedRefreshToken",
5050
},
51-
Dashboard: user.Dashboard{
52-
Grants: []string{"grant1", "grant2"},
53-
},
5451
},
5552
}
5653
}

reload-server.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
go build -o ynufes-mypage-backend ./svc/cmd/dev/main.go
2+
sudo systemctl restart ynufes-mypage

0 commit comments

Comments
 (0)