diff --git a/index.js b/index.js index 640c160..a877860 100644 --- a/index.js +++ b/index.js @@ -1,13 +1,13 @@ import fetch from 'node-fetch'; import postgres from 'postgres'; -import {drizzle} from 'drizzle-orm/postgres-js'; -import {pgTable, text} from 'drizzle-orm/pg-core'; +import { drizzle } from 'drizzle-orm/postgres-js'; +import { pgTable, text } from 'drizzle-orm/pg-core'; // PostgreSQL 데이터베이스 연결 설정 const sql = postgres({ host: '172.30.1.93', // PostgreSQL 호스트 port: 5432, // 포트 (기본값: 5432) - database: 'bizinfo', // 데이터베이스 이름 + database: 'bizinfo', // 데이터베이스 이름 username: 'postgres', // 사용자 이름 password: 'Dlstjq0904!' // 비밀번호 }); @@ -155,24 +155,22 @@ const niceTable = pgTable('nice', { async function main() { const baseUrl = 'https://nice.kegorii.workers.dev/get?t='; - const firstArray = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'H', 'I', 'J', 'L', 'M', 'N', 'O', 'P', 'Q'] + const firstArray = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'H', 'I', 'J', 'L', 'M', 'N', 'O', 'P', 'Q']; for (let i = 0; i < firstArray.length; i++) { let secondArray = []; if (i >= 0 && i <= 9) { secondArray = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; - } else { secondArray = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; } - console.log(secondArray); for (let x = 0; x < secondArray.length; x++) { for (let y = 5; y < 20; y++) { const rtnval = y.toString().padStart(3, '0'); - const kiscode = firstArray[i] + secondArray[x] + rtnval; const url = `${baseUrl}${kiscode}`; - console.log(firstArray[i] + secondArray[x] + rtnval); try { + const startTime = Date.now(); // 시작 시간 저장 + const response = await fetch(url); if (!response.ok) { @@ -186,12 +184,13 @@ async function main() { if (insertValues.length > 0) { await orm.insert(niceTable).values(insertValues); - } + + const endTime = Date.now(); // 종료 시간 저장 + console.log(`Execution time for kiscode:${kiscode}: ${endTime - startTime} ms`); // 콘솔에 시간 출력 } catch (error) { console.error(`Error at kiscode:${kiscode}`, error); } - console.log('ok'); } } }