Skip to content
This repository was archived by the owner on Dec 26, 2023. It is now read-only.

Commit 7c5d441

Browse files
authored
Merge pull request #3 from 9renpoto/master
refactor: format and tests Pull requestsありがとうございました。
2 parents 7060dd5 + 16fcfff commit 7c5d441

10 files changed

Lines changed: 5755 additions & 173 deletions

File tree

.github/workflows/node.js.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
node-version: [12.x, 14.x, 16.x]
20+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
cache: 'npm'
29+
- run: npm ci
30+
- run: npm run build --if-present
31+
- run: npm test

.gitignore

Lines changed: 122 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,122 @@
1-
/node_modules
2-
# setting.yaml
1+
### https://raw.github.com/github/gitignore/cdd9e946da421758c6f42c427c7bc65c8326155d/Node.gitignore
2+
3+
# Logs
4+
logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
lerna-debug.log*
10+
.pnpm-debug.log*
11+
12+
# Diagnostic reports (https://nodejs.org/api/report.html)
13+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
14+
15+
# Runtime data
16+
pids
17+
*.pid
18+
*.seed
19+
*.pid.lock
20+
21+
# Directory for instrumented libs generated by jscoverage/JSCover
22+
lib-cov
23+
24+
# Coverage directory used by tools like istanbul
25+
coverage
26+
*.lcov
27+
28+
# nyc test coverage
29+
.nyc_output
30+
31+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
32+
.grunt
33+
34+
# Bower dependency directory (https://bower.io/)
35+
bower_components
36+
37+
# node-waf configuration
38+
.lock-wscript
39+
40+
# Compiled binary addons (https://nodejs.org/api/addons.html)
41+
build/Release
42+
43+
# Dependency directories
44+
node_modules/
45+
jspm_packages/
46+
47+
# Snowpack dependency directory (https://snowpack.dev/)
48+
web_modules/
49+
50+
# TypeScript cache
51+
*.tsbuildinfo
52+
53+
# Optional npm cache directory
54+
.npm
55+
56+
# Optional eslint cache
57+
.eslintcache
58+
59+
# Microbundle cache
60+
.rpt2_cache/
61+
.rts2_cache_cjs/
62+
.rts2_cache_es/
63+
.rts2_cache_umd/
64+
65+
# Optional REPL history
66+
.node_repl_history
67+
68+
# Output of 'npm pack'
69+
*.tgz
70+
71+
# Yarn Integrity file
72+
.yarn-integrity
73+
74+
# dotenv environment variables file
75+
.env
76+
.env.test
77+
.env.production
78+
79+
# parcel-bundler cache (https://parceljs.org/)
80+
.cache
81+
.parcel-cache
82+
83+
# Next.js build output
84+
.next
85+
out
86+
87+
# Nuxt.js build / generate output
88+
.nuxt
89+
dist
90+
91+
# Gatsby files
92+
.cache/
93+
# Comment in the public line in if your project uses Gatsby and not Next.js
94+
# https://nextjs.org/blog/next-9-1#public-directory-support
95+
# public
96+
97+
# vuepress build output
98+
.vuepress/dist
99+
100+
# Serverless directories
101+
.serverless/
102+
103+
# FuseBox cache
104+
.fusebox/
105+
106+
# DynamoDB Local files
107+
.dynamodb/
108+
109+
# TernJS port file
110+
.tern-port
111+
112+
# Stores VSCode versions used for testing VSCode extensions
113+
.vscode-test
114+
115+
# yarn v2
116+
.yarn/cache
117+
.yarn/unplugged
118+
.yarn/build-state.yml
119+
.yarn/install-state.gz
120+
.pnp.*
121+
122+

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

README.md

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
# gcs-basic-authとは
1+
# gcs-basic-auth とは
22

3-
4-
gcs-basic-authは、Google Cloud Storage(以下、GCS)のファイルをBasic認証をつけて公開するためプログラムです。
3+
gcs-basic-auth は、Google Cloud Storage(以下、GCS)のファイルを Basic 認証をつけて公開するためプログラムです。
54
Google App Engine(以下、GAE)にデプロイして使用します。
65

7-
GAEにアクセスされるとBasic認証を表示し、認証されるとリバースプロキシのように動いてGCSのファイルをユーザに転送します
6+
GAE にアクセスされると Basic 認証を表示し、認証されるとリバースプロキシのように動いて GCS のファイルをユーザに転送します
87

98
# How it works
109

@@ -24,19 +23,18 @@ env_variables:
2423
BASIC_AUTH_PASSWORD: 'hoge_password'#<-Basic認証で入力させたいパスワード
2524
```
2625
27-
3.GAEのstandard(node)にデプロイ
26+
3.GAE の standard(node)にデプロイ
2827
29-
4.GAEにアクセスして表示を確認
28+
4.GAE にアクセスして表示を確認
3029
31-
表示されない場合、IAMの権限が足りているか、stackDrive Loggingページを確認します
30+
表示されない場合、IAM の権限が足りているか、stackDrive Logging ページを確認します
3231
3332
```
3433
Management (IAM) API has not been used in project
3534
```
3635

3736
などが、出ているときは指示に従って権限を追加します。
3837

39-
4038
# その他設定系
4139

4240
```yaml
@@ -72,27 +70,27 @@ env_variables:
7270
7371
### 転送モードについて
7472
75-
設定のTRANSFER_MODE(転送モード)について説明します。
73+
設定の TRANSFER_MODE(転送モード)について説明します。
7674
77-
転送の基本的な動きは、ユーザがアクセスすると、GAEが `GCS->GAE->ブラウザ/ユーザ` と流れます。
78-
ただし、GAEのstandardは60秒しか動作しないため、巨大ファイルだと転送が間に合わない可能性があります。
79-
そこで、GCSの署名付きURL(一定期間のみ使用可能なURL)を使い、ファイル転送をGCSから行います
75+
転送の基本的な動きは、ユーザがアクセスすると、GAE が `GCS->GAE->ブラウザ/ユーザ` と流れます。
76+
ただし、GAE の standard は 60 秒しか動作しないため、巨大ファイルだと転送が間に合わない可能性があります。
77+
そこで、GCS の署名付き URL(一定期間のみ使用可能な URL)を使い、ファイル転送を GCS から行います
8078
転送の流れが、 `GAE->(署名付きURL)->ブラウザ->(リダイレクト)->GCS->(ファイル転送)->ブラウザ` とすることで巨大ファイルの問題を解決できます。
81-
また、GCS->GAEと経由するより直接転送したほうが安くなります
82-
ただし、HTMLを署名付きURLで取得すると、正常に機能しません。
83-
URLがGCSになるため、HTMLはGCSを起点にファイルを取得しようとし、失敗します。
84-
これは、CSSやJSにも当てはまります
79+
また、GCS->GAE と経由するより直接転送したほうが安くなります
80+
ただし、HTML を署名付き URL で取得すると、正常に機能しません。
81+
URL が GCS になるため、HTML は GCS を起点にファイルを取得しようとし、失敗します。
82+
これは、CSS や JS にも当てはまります
8583

86-
どのファイルをGCS署名付きURLを使うかの設定が転送モードです
84+
どのファイルを GCS 署名付き URL を使うかの設定が転送モードです
8785

88-
+ TRANSFER_MODE: 'ALL_DIRECT' => すべてのファイルはGAEを経由して転送
89-
+ TRANSFER_MODE: 'ALLOW_DIRECT' => ALLOW_DIRECT_LISTに記載したファイルのみGAEを経由して転送
90-
+ TRANSFER_MODE: 'ALLOW_REDIRECT' => ALLOW_REDIRECT_LISTに記載されていないファイルをGAEを経由して転送
86+
- TRANSFER_MODE: 'ALL_DIRECT' => すべてのファイルは GAE を経由して転送
87+
- TRANSFER_MODE: 'ALLOW_DIRECT' => ALLOW_DIRECT_LIST に記載したファイルのみ GAE を経由して転送
88+
- TRANSFER_MODE: 'ALLOW_REDIRECT' => ALLOW_REDIRECT_LIST に記載されていないファイルを GAE を経由して転送
9189

92-
ALLOW_DIRECT_LISTと、ALLOW_REDIRECT_LISTには、対象としたいファイルの拡張子を記載下さい。
90+
ALLOW_DIRECT_LIST と、ALLOW_REDIRECT_LIST には、対象としたいファイルの拡張子を記載下さい。
9391

94-
また、署名付きURLの有効時間は、GCS_URL_LIFETIMEで設定できます。(初期値:1時間)
92+
また、署名付き URL の有効時間は、GCS_URL_LIFETIME で設定できます。(初期値:1 時間)
9593

96-
GAE転送する必要があり、60秒で間に合わない場合は
94+
GAE 転送する必要があり、60 秒で間に合わない場合は
9795
`app.yaml`の`env: standard` => `env: flexible`に変更することで接続時間を伸ばせます。
9896
ただし、サーバスケールが分速に遅くなるので、ある程度サーバ台数を確保しておく必要があります。

SECURITY.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
Use this section to tell people about which versions of your project are
6+
currently being supported with security updates.
7+
8+
| Version | Supported |
9+
| ------- | ------------------ |
10+
| 5.1.x | :white_check_mark: |
11+
| 5.0.x | :x: |
12+
| 4.0.x | :white_check_mark: |
13+
| < 4.0 | :x: |
14+
15+
## Reporting a Vulnerability
16+
17+
Use this section to tell people how to report a vulnerability.
18+
19+
Tell them where to go, how often they can expect to get an update on a
20+
reported vulnerability, what to expect if the vulnerability is accepted or
21+
declined, etc.

app.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ runtime: nodejs10
22
env: standard
33
instance_class: F2
44
includes:
5-
- setting.yaml
5+
- setting.yaml

0 commit comments

Comments
 (0)