diff --git a/package.json b/package.json index f8e8eda0..25efc6a0 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "axios": "^0.27.2", "classcat": "^5.0.4", "dayjs": "^1.11.3", - "googleapis": "126.0.0", "nanoid": "4.0.2", "next": "13.3.0", "qs": "6.11.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ebdac263..e00276ae 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40,7 +40,6 @@ specifiers: eslint-plugin-react: ^7.30.0 eslint-plugin-react-hooks: ^4.5.0 git-cz: ^4.9.0 - googleapis: 126.0.0 husky: ^8.0.1 jest: ^28.1.0 jest-environment-jsdom: ^28.1.0 @@ -76,7 +75,6 @@ dependencies: axios: 0.27.2 classcat: 5.0.4 dayjs: 1.11.9 - googleapis: 126.0.0 nanoid: 4.0.2 next: 13.3.0_i7fbsmp6luydialx2h65cfhsq4 qs: 6.11.1 @@ -2804,15 +2802,6 @@ packages: - supports-color dev: true - /agent-base/7.1.0: - resolution: {integrity: sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==} - engines: {node: '>= 14'} - dependencies: - debug: 4.3.4 - transitivePeerDependencies: - - supports-color - dev: false - /aggregate-error/3.1.0: resolution: {integrity: sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==} engines: {node: '>=8'} @@ -3170,10 +3159,6 @@ packages: /balanced-match/1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - /base64-js/1.5.1: - resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - dev: false - /big-integer/1.6.51: resolution: {integrity: sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==} engines: {node: '>=0.6'} @@ -3183,10 +3168,6 @@ packages: resolution: {integrity: sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==} dev: true - /bignumber.js/9.1.2: - resolution: {integrity: sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==} - dev: false - /binary-extensions/2.2.0: resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} engines: {node: '>=8'} @@ -3247,10 +3228,6 @@ packages: node-int64: 0.4.0 dev: true - /buffer-equal-constant-time/1.0.1: - resolution: {integrity: sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==} - dev: false - /buffer-from/1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} dev: true @@ -3744,12 +3721,6 @@ packages: domhandler: 5.0.3 dev: true - /ecdsa-sig-formatter/1.0.11: - resolution: {integrity: sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==} - dependencies: - safe-buffer: 5.2.1 - dev: false - /electron-to-chromium/1.4.508: resolution: {integrity: sha512-FFa8QKjQK/A5QuFr2167myhMesGrhlOBD+3cYNxO9/S4XzHEXesyTD/1/xF644gC8buFPz3ca6G1LOQD0tZrrg==} @@ -4355,10 +4326,6 @@ packages: jest-util: 28.1.3 dev: true - /extend/3.0.2: - resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} - dev: false - /fast-deep-equal/3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} dev: true @@ -4514,30 +4481,6 @@ packages: resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} dev: true - /gaxios/6.1.0: - resolution: {integrity: sha512-EIHuesZxNyIkUGcTQKQPMICyOpDD/bi+LJIJx+NLsSGmnS7N+xCLRX5bi4e9yAu9AlSZdVq+qlyWWVuTh/483w==} - engines: {node: '>=14'} - dependencies: - extend: 3.0.2 - https-proxy-agent: 7.0.1 - is-stream: 2.0.1 - node-fetch: 2.7.0 - transitivePeerDependencies: - - encoding - - supports-color - dev: false - - /gcp-metadata/6.0.0: - resolution: {integrity: sha512-Ozxyi23/1Ar51wjUT2RDklK+3HxqDr8TLBNK8rBBFQ7T85iIGnXnVusauj06QyqCXRFZig8LZC+TUddWbndlpQ==} - engines: {node: '>=14'} - dependencies: - gaxios: 6.1.0 - json-bigint: 1.0.0 - transitivePeerDependencies: - - encoding - - supports-color - dev: false - /gensync/1.0.0-beta.2: resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} engines: {node: '>=6.9.0'} @@ -4656,48 +4599,6 @@ packages: slash: 3.0.0 dev: true - /google-auth-library/9.0.0: - resolution: {integrity: sha512-IQGjgQoVUAfOk6khqTVMLvWx26R+yPw9uLyb1MNyMQpdKiKt0Fd9sp4NWoINjyGHR8S3iw12hMTYK7O8J07c6Q==} - engines: {node: '>=14'} - dependencies: - base64-js: 1.5.1 - ecdsa-sig-formatter: 1.0.11 - gaxios: 6.1.0 - gcp-metadata: 6.0.0 - gtoken: 7.0.1 - jws: 4.0.0 - lru-cache: 6.0.0 - transitivePeerDependencies: - - encoding - - supports-color - dev: false - - /googleapis-common/7.0.0: - resolution: {integrity: sha512-58iSybJPQZ8XZNMpjrklICefuOuyJ0lMxfKmBqmaC0/xGT4SiOs4BE60LAOOGtBURy1n8fHa2X2YUNFEWWbXyQ==} - engines: {node: '>=14.0.0'} - dependencies: - extend: 3.0.2 - gaxios: 6.1.0 - google-auth-library: 9.0.0 - qs: 6.11.1 - url-template: 2.0.8 - uuid: 9.0.0 - transitivePeerDependencies: - - encoding - - supports-color - dev: false - - /googleapis/126.0.0: - resolution: {integrity: sha512-BeCwYJfthEWUgY0ka7msSxyMuRwrwJTqL9yMlnuCxyy1JlRZwaI5ZVVp4ofwiGiNP9UuuR3Yk9CJKWQLg4Tq1A==} - engines: {node: '>=14.0.0'} - dependencies: - google-auth-library: 9.0.0 - googleapis-common: 7.0.0 - transitivePeerDependencies: - - encoding - - supports-color - dev: false - /gopd/1.0.1: resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} dependencies: @@ -4712,17 +4613,6 @@ packages: resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} dev: true - /gtoken/7.0.1: - resolution: {integrity: sha512-KcFVtoP1CVFtQu0aSk3AyAt2og66PFhZAlkUOuWKwzMLoulHXG5W5wE5xAnHb+yl3/wEFoqGW7/cDGMU8igDZQ==} - engines: {node: '>=14.0.0'} - dependencies: - gaxios: 6.1.0 - jws: 4.0.0 - transitivePeerDependencies: - - encoding - - supports-color - dev: false - /has-bigints/1.0.2: resolution: {integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==} dev: true @@ -4810,16 +4700,6 @@ packages: - supports-color dev: true - /https-proxy-agent/7.0.1: - resolution: {integrity: sha512-Eun8zV0kcYS1g19r78osiQLEFIRspRUDd9tIfBCTBPBeMieF/EsJNL8VI3xOIdYRDEkjQnqOYPsZ2DsWsVsFwQ==} - engines: {node: '>= 14'} - dependencies: - agent-base: 7.1.0 - debug: 4.3.4 - transitivePeerDependencies: - - supports-color - dev: false - /human-signals/2.1.0: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} engines: {node: '>=10.17.0'} @@ -5050,6 +4930,7 @@ packages: /is-stream/2.0.1: resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} engines: {node: '>=8'} + dev: true /is-string/1.0.7: resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} @@ -5668,12 +5549,6 @@ packages: engines: {node: '>=4'} hasBin: true - /json-bigint/1.0.0: - resolution: {integrity: sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==} - dependencies: - bignumber.js: 9.1.2 - dev: false - /json-buffer/3.0.1: resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} dev: true @@ -5716,21 +5591,6 @@ packages: object.values: 1.1.7 dev: true - /jwa/2.0.0: - resolution: {integrity: sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA==} - dependencies: - buffer-equal-constant-time: 1.0.1 - ecdsa-sig-formatter: 1.0.11 - safe-buffer: 5.2.1 - dev: false - - /jws/4.0.0: - resolution: {integrity: sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg==} - dependencies: - jwa: 2.0.0 - safe-buffer: 5.2.1 - dev: false - /keyv/4.5.3: resolution: {integrity: sha512-QCiSav9WaX1PgETJ+SpNnx2PRRapJ/oRSXM4VO5OGYGSjrxbKPVFVhB3l2OCbLCk329N8qyAtsJjSjvVBWzEug==} dependencies: @@ -5890,6 +5750,7 @@ packages: engines: {node: '>=10'} dependencies: yallist: 4.0.0 + dev: true /lz-string/1.5.0: resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==} @@ -6089,18 +5950,6 @@ packages: - babel-plugin-macros dev: false - /node-fetch/2.7.0: - resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} - engines: {node: 4.x || >=6.0.0} - peerDependencies: - encoding: ^0.1.0 - peerDependenciesMeta: - encoding: - optional: true - dependencies: - whatwg-url: 5.0.0 - dev: false - /node-int64/0.4.0: resolution: {integrity: sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==} dev: true @@ -6793,6 +6642,7 @@ packages: /safe-buffer/5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} + dev: true /safe-regex-test/1.0.0: resolution: {integrity: sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==} @@ -7241,10 +7091,6 @@ packages: url-parse: 1.5.10 dev: true - /tr46/0.0.3: - resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} - dev: false - /tr46/3.0.0: resolution: {integrity: sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==} engines: {node: '>=12'} @@ -7489,15 +7335,6 @@ packages: requires-port: 1.0.0 dev: true - /url-template/2.0.8: - resolution: {integrity: sha512-XdVKMF4SJ0nP/O7XIPB0JwAEuT9lDIYnNsK8yGVe43y0AWoKeJNdv3ZNWh7ksJ6KqQFjOO6ox/VEitLnaVNufw==} - dev: false - - /uuid/9.0.0: - resolution: {integrity: sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==} - hasBin: true - dev: false - /v8-to-istanbul/9.1.0: resolution: {integrity: sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA==} engines: {node: '>=10.12.0'} @@ -7535,10 +7372,6 @@ packages: graceful-fs: 4.2.11 dev: true - /webidl-conversions/3.0.1: - resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} - dev: false - /webidl-conversions/7.0.0: resolution: {integrity: sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==} engines: {node: '>=12'} @@ -7617,13 +7450,6 @@ packages: webidl-conversions: 7.0.0 dev: true - /whatwg-url/5.0.0: - resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} - dependencies: - tr46: 0.0.3 - webidl-conversions: 3.0.1 - dev: false - /which-boxed-primitive/1.0.2: resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==} dependencies: @@ -7741,6 +7567,7 @@ packages: /yallist/4.0.0: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} + dev: true /yaml/1.10.2: resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==} diff --git a/src/lib/constants/googlesheet-env.ts b/src/lib/constants/googlesheet-env.ts deleted file mode 100644 index 9f5b915e..00000000 --- a/src/lib/constants/googlesheet-env.ts +++ /dev/null @@ -1,13 +0,0 @@ -export const googleSheetCredential = { - type: 'service_account', - project_id: process.env.NEXT_GOOGLE_SHEET_PROJECT_ID, - private_key_id: process.env.NEXT_GOOGLE_SHEET_PRIVATE_KEY_ID, - private_key: process.env.NEXT_GOOGLE_SHEET_PRIVATE_KEY?.split(String.raw`\n`).join('\n'), - client_email: process.env.NEXT_GOOGLE_SHEET_CLIENT_EMAIL, - client_id: process.env.NEXT_GOOGLE_SHEET_CLIENT_ID, - auth_uri: process.env.NEXT_GOOGLE_SHEET_AUTH_URI, - token_uri: process.env.NEXT_GOOGLE_SHEET_TOKEN_URI, - auth_provider_x509_cert_url: process.env.NEXT_GOOGLE_SHEET_AUTH_PROVIDER_X509_CERT_URL, - client_x509_cert_url: process.env.NEXT_GOOGLE_SHEET_CLIENT_X509_CERT_URL, - universe_domain: process.env.NEXT_GOOGLE_SHEET_UNIVERSE_DOMAIN, -}; diff --git a/src/pages/api/register.ts b/src/pages/api/register.ts deleted file mode 100644 index 4e5677ff..00000000 --- a/src/pages/api/register.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { NextApiRequest, NextApiResponse } from 'next'; -import { googleSheetCredential } from '@src/lib/constants/googlesheet-env'; -import { google } from 'googleapis'; - -export default async function handler(request: NextApiRequest, response: NextApiResponse) { - try { - if (request.method === 'POST') { - const resultStatus = await writeRow(request.body.email); - return response.status(200).json({ success: resultStatus === 200, resultStatus }); - } - } catch (error) { - return response.status(500).json({ error }); - } - - return response.status(200).json({ success: true }); -} - -export const writeRow = async (email: string) => { - const now = new Date(); - const dateString = `${now.toDateString()} ${now.toTimeString()}`; - const auth = new google.auth.GoogleAuth({ - credentials: { - client_email: googleSheetCredential.client_email, - client_id: googleSheetCredential.client_id, - private_key: googleSheetCredential.private_key, - }, - scopes: ['https://www.googleapis.com/auth/spreadsheets'], - }); - // google spread sheet api 가져오기 - const googleSheet = google.sheets({ - version: 'v4', - auth, - }); - const result = await googleSheet.spreadsheets.values.append({ - spreadsheetId: '1u1gRgpx7PEKYkG8VPfqQZQ2BI5c2OHaj0UnYs5uaQ6E', - range: 'A:B', - valueInputOption: 'USER_ENTERED', - requestBody: { values: [[email, dateString]] }, - }); - return result.status; -}; diff --git a/src/views/RecruitPage/components/NotificationSection/index.tsx b/src/views/RecruitPage/components/NotificationSection/index.tsx index e3ee9370..a6ef6ee0 100644 --- a/src/views/RecruitPage/components/NotificationSection/index.tsx +++ b/src/views/RecruitPage/components/NotificationSection/index.tsx @@ -1,7 +1,13 @@ import { track } from '@amplitude/analytics-browser'; import styled from '@emotion/styled'; -import { useRef, useState } from 'react'; +import { BASE_URL, DEFAULT_TIMEOUT } from '@src/lib/constants/client'; import axios from 'axios'; +import { useRef, useState } from 'react'; + +const client = axios.create({ + baseURL: BASE_URL, + timeout: DEFAULT_TIMEOUT, +}); const NotificationSection = () => { const [isRegistered, setIsRegistered] = useState(false); @@ -14,10 +20,11 @@ const NotificationSection = () => { const email = emailInputRef.current?.value; if (!email) return; setIsLoading(true); - const result = await axios.post('/api/register', { + const result = await client.post('/notification/register', { + generation: 34, // 리크루팅 시기 이후 변경되어야 함. email, }); - if (result.data.success) { + if (result.status === 201) { if (emailInputRef.current?.value) { emailInputRef.current.value = ''; }