From 617523094408f19b468f6bfa08085e54d7bc5e15 Mon Sep 17 00:00:00 2001 From: kem Date: Mon, 6 Jan 2025 14:14:46 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20getCompanies=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 4 ++++ src/http/companies_kem.http | 5 +++++ src/routes/getCompanies_Kem.js | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 src/http/companies_kem.http create mode 100644 src/routes/getCompanies_Kem.js diff --git a/server.js b/server.js index 45a67f0..895cf59 100644 --- a/server.js +++ b/server.js @@ -16,6 +16,7 @@ import getCompanies_ksh from './src/routes/getCompanies_ksh.js'; import createInvestment_ksh from './src/routes/createInvestment_ksh.js'; import patchInvestment_ksh from './src/routes/patchInvestment_ksh.js'; import deleteInvestment_ksh from './src/routes/deleteInvestment_ksh.js'; +import getConmpanies_Kem from './src/routes/getCompanies_Kem.js'; dotenv.config(); export const app = express(); @@ -64,4 +65,7 @@ app.use('/api/kjy', getCompanyDetail_kjy); // 해당 기업에 투자한 투자자 목록 조회(김주영) app.use('/api/kjy', getInvesterList_kjy); +// 기업 목록 조회(구은모) +app.use('/api/kem', getConmpanies_Kem); + app.listen(process.env.PORT || 5500, () => console.log('Server Started')); diff --git a/src/http/companies_kem.http b/src/http/companies_kem.http new file mode 100644 index 0000000..939cf37 --- /dev/null +++ b/src/http/companies_kem.http @@ -0,0 +1,5 @@ +GET http://localhost:5500/api/kem/companies + +### + +GET http://localhost:5500/api/jhm/companies \ No newline at end of file diff --git a/src/routes/getCompanies_Kem.js b/src/routes/getCompanies_Kem.js new file mode 100644 index 0000000..f7d451c --- /dev/null +++ b/src/routes/getCompanies_Kem.js @@ -0,0 +1,19 @@ +//구은모 + +import express from 'express'; +import { PrismaClient } from '@prisma/client'; +import asyncHandler from '../controllers/asyncHandler.js'; +import { convertToBigIntFromObjArray } from '../controllers/convertToBigIntFromObjArray.js'; + +const router = express.Router(); +const prisma = new PrismaClient(); + +router.get( + '/api/kem/companies', + asyncHandler(async (req, res) => { + const companies = await prisma.company.findMany(); + res.send(convertToBigIntFromObjArray(companies)); + }) +); + +export default router; \ No newline at end of file