Skip to content

Commit

Permalink
Merge pull request #136 from codeforjapan/feature/133-add-production-…
Browse files Browse the repository at this point in the history
…stage

feature/133-add-production-stage
  • Loading branch information
halsk authored Mar 20, 2021
2 parents c769a14 + dc0f945 commit 603c399
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- name: npm install
run: |
cp config/stg.json.sample config/stg.json # for ignoring install error
cp config/stg.json.sample config/prd.json # for ignoring install error
npm install
- name: build swagger yaml
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ util/.secret.json
templates/swagger.yaml
dist/**
config/stg.json
config/prd.json
src/gh-swagger-ui/swagger.yaml
templates/functions-.yml
templates/functions-true.yml
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@
"stg:createAdmin": "util/create_admin.sh -s stg",
"stg:confirmAdmin": "util/confirm_admin.sh -s stg",
"stg:test:e2e": "util/delete_all_cognito_users.sh -s stg && JEST_STAGE=\"stg\" jest --silent=false --runInBand test/e2e",
"stg:remove:all": "run-s \"remove:gateway -- --stage stg\" \"remove:dynamodb -- --stage stg\""
"stg:remove:all": "run-s \"remove:gateway -- --stage stg\" \"remove:dynamodb -- --stage stg\"",
"prd:deploy": "run-s \"deploy:dynamodb -- --stage prd\" prd:deploy:all-gateway",
"prd:deploy:all-gateway": "run-s build:functions-yaml \"deploy:lambda -- --stage prd\" prd:deploy:gateway",
"prd:deploy:gateway": "run-s build:functions-yaml \"build:swagger-yaml -- --stage prd\" \"deploy:gateway-force -- --stage prd\"",
"prd:createAdmin": "util/create_admin.sh -s prd",
"prd:confirmAdmin": "util/confirm_admin.sh -s prd"
},
"name": "remote-patient-monitoring",
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/lambda/patient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const sendLoginURLSMS = async (param: {
accessKey: process.env.SMS_ACCESSKEY || "",
};
let loginURL = "http://localhost:8000/#/login/";
if (process.env.STAGE && process.env.STAGE == "stg") {
if (process.env.STAGE && (process.env.STAGE == "stg" || process.env.STAGE == "prd")) {
loginURL = process.env.LOGINURL || loginURL;
const smsSender = new SMSSender(endpoint, logininfo);
console.log("Call SEND SMS");
Expand Down
1 change: 1 addition & 0 deletions src/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ info:
version: 1.0.0
servers:
- url: https://monitoring.stopcovid19.jp/stg/
- url: https://monitoring.stopcovid19.jp/prd/
paths:
/api/admin/login:
$ref: ./paths/admin/login.yaml
Expand Down
10 changes: 6 additions & 4 deletions src/util/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,21 @@ export default class Validator {
return true;
}

isNurseAPI(event: APIGatewayProxyEvent) {
isNurseAPI(event: APIGatewayProxyEvent): boolean {
if (!event.path) return false;
return (
event.path.startsWith("/api/nurse/") ||
event.path.startsWith("/stg/api/nurse/")
event.path.startsWith("/stg/api/nurse/") ||
event.path.startsWith("/prd/api/nurse/")
);
}

isPatientAPI(event: APIGatewayProxyEvent) {
isPatientAPI(event: APIGatewayProxyEvent): boolean {
if (!event.path) return false;
return (
event.path.startsWith("/api/patient/") ||
event.path.startsWith("/stg/api/patient/")
event.path.startsWith("/stg/api/patient/") ||
event.path.startsWith("/prd/api/patient/")
);
}
}
3 changes: 2 additions & 1 deletion util/truncatedb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AWS, { DynamoDB } from 'aws-sdk';
import * as configsys from '../src/webpack/config';
import configFileDev from '../config/dev.json';
import configFileStg from '../config/stg.json';
import configFilePrd from '../config/prd.json';

let profile = 'default';
if (process.env.AWS_PROFILE) {
Expand All @@ -20,7 +21,7 @@ export class TruncateDB {
private configFile: any;
private config: configsys.Config;
constructor(stage: string) {
this.configFile = (stage === 'stg') ? configFileStg : configFileDev;
this.configFile = (stage === 'prd') ? configFilePrd : (stage === 'stg') ? configFileStg : configFileDev;
this.config = configsys.readConfig(stage)
AWS.config.update({ region: this.config.region });
AWS.config.credentials = credentials;
Expand Down

0 comments on commit 603c399

Please sign in to comment.