diff --git a/dictation_function/package.json b/dictation_function/package.json index 0be5119..1f1524a 100644 --- a/dictation_function/package.json +++ b/dictation_function/package.json @@ -9,7 +9,8 @@ "clean": "rimraf dist", "prestart": "npm run clean && npm run build", "start": "func start", - "test": "sql-migrate up -config=/app/dictation_server/db/dbconfig.yml -env=test && jest -w 1", + "test": "tsc --noEmit && sql-migrate up -config=/app/dictation_server/db/dbconfig.yml -env=test && jest -w 1", + "typecheck": "tsc --noEmit", "codegen": "sh codegen.sh" }, "dependencies": { diff --git a/dictation_function/src/functions/licenseAutoAllocation.ts b/dictation_function/src/functions/licenseAutoAllocation.ts index 80d4414..8b1b053 100644 --- a/dictation_function/src/functions/licenseAutoAllocation.ts +++ b/dictation_function/src/functions/licenseAutoAllocation.ts @@ -97,23 +97,7 @@ export async function licenseAutoAllocation( context.log("[IN]licenseAutoAllocation"); dotenv.config({ path: ".env" }); dotenv.config({ path: ".env.local", override: true }); - let datasource: DataSource; - try { - datasource = new DataSource({ - type: "mysql", - host: process.env.DB_HOST, - port: Number(process.env.DB_PORT), - username: process.env.DB_USERNAME, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - entities: [User, Account, License, LicenseAllocationHistory], - }); - await datasource.initialize(); - } catch (e) { - context.log("database initialize failed."); - context.error(e); - throw e; - } + const datasource = await initializeDataSource(context); let redisClient: RedisClient; try { // redis接続 diff --git a/dictation_function/src/functions/licenseAutoAllocationManualRetry.ts b/dictation_function/src/functions/licenseAutoAllocationManualRetry.ts index b9d74e8..c4b4514 100644 --- a/dictation_function/src/functions/licenseAutoAllocationManualRetry.ts +++ b/dictation_function/src/functions/licenseAutoAllocationManualRetry.ts @@ -41,23 +41,7 @@ export async function licenseAutoAllocationManualRetry( context.log("[IN]licenseAutoAllocationManualRetry"); dotenv.config({ path: ".env" }); dotenv.config({ path: ".env.local", override: true }); - let datasource: DataSource; - try { - datasource = new DataSource({ - type: "mysql", - host: process.env.DB_HOST, - port: Number(process.env.DB_PORT), - username: process.env.DB_USERNAME, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - entities: [User, Account, License, LicenseAllocationHistory], - }); - await datasource.initialize(); - } catch (e) { - context.log("database initialize failed."); - context.error(e); - throw e; - } + const datasource = await initializeDataSource(context); let redisClient: RedisClient; try { // redis接続