Quellcode durchsuchen

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

develop
sosuke.iwabuchi vor 2 Jahren
Ursprung
Commit
5b50319e62
4 geänderte Dateien mit 6 neuen und 14 gelöschten Zeilen
  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 Datei anzeigen

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


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


const config = myPageConfig();

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




+ 1
- 1
src/mypage/メール.ts Datei anzeigen

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


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

+ 0
- 5
types/env.d.ts Datei anzeigen

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


+ 0
- 2
webpack.config.js Datei anzeigen

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

}), }),
], ],
}; };

Laden…
Abbrechen
Speichern