Browse Source

envからでなく、configから各設定値を取り込むように修正

develop
sosuke.iwabuchi 2 years ago
parent
commit
5b50319e62
4 changed files with 6 additions and 14 deletions
  1. +5
    -6
      src/mypage/lib.ts
  2. +1
    -1
      src/mypage/メール.ts
  3. +0
    -5
      types/env.d.ts
  4. +0
    -2
      webpack.config.js

+ 5
- 6
src/mypage/lib.ts View File

@@ -1,22 +1,21 @@
import { myPageConfig } from "@/config/mypage";
import { MyPageApiID } from ".";

type MyPageApiResponse = {
result: "SUCCESS" | "FAILED";
};

const config = myPageConfig();

export const getUrl = (apiId: MyPageApiID) => {
return [
process.env.VAR.MYPAGE_BASE_URL ?? "",
"api-from-kintone",
apiId,
].join("/");
return [config.BASE_URL, "api-from-kintone", apiId].join("/");
};

export const send = async (apiId: MyPageApiID, data: object) => {
const url = getUrl(apiId);
const sendData = {
...data,
token: process.env.VAR.MYPAGE_TOKEN ?? "",
token: config.TOKEN ?? "",
};
console.info("MyPageAPICall", url, data);



+ 1
- 1
src/mypage/メール.ts View File

@@ -1,3 +1,4 @@
import { myPageConfig } from "@/config/mypage";
import { MyPageApiID } from ".";
import { send } from "./lib";

@@ -31,7 +32,6 @@ export const sendEmail = (
email_id: id,
...(data ?? {}),
...key,
token: process.env.MYPAGE_TOKEN ?? "",
};
return send(MyPageApiID.メール送信依頼, sendData);
};

+ 0
- 5
types/env.d.ts View File

@@ -2,11 +2,6 @@ declare global {
namespace NodeJS {
interface ProcessEnv {
NODE_ENV: "development" | "production" | "test";
// 他の環境変数も追加できます
VAR: {
MYPAGE_BASE_URL: string;
MYPAGE_TOKEN: string;
};
BUILD_TIME: string;
}
}


+ 0
- 2
webpack.config.js View File

@@ -105,9 +105,7 @@ module.exports = {
},
},
new webpack.DefinePlugin({
'process.env.VAR': JSON.stringify(env),
'process.env.BUILD_TIME': JSON.stringify(format(new Date(), 'yyyy-MM-dd HH:mm:ss')),

}),
],
};

Loading…
Cancel
Save