Node.js용 예약 서버 스켈레톤
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Node.js를 기반으로 하는 표준 통합을 위한 API v3 예약 서버의 참조 구현입니다.
기본 요건
다음을 설치해야 함
시작하기
예시를 위해 예약 서버는 추가 라이브러리 또는 프레임워크 없이 표준 Node.js를 사용하여 구현됩니다. 다른 프레임워크를 사용하는 경우 이 구현을 Express.js, MEAN.js 또는 원하는 다른 Node.js 기반 프레임워크로 쉽게 변경할 수 있습니다.
또한 이 구현은 프로토콜 버퍼 라이브러리를 사용하지 않고 간단한 JSON 직렬화와 JSON.parse() 및 JSON.stringify() 메서드를 사용합니다.
프로젝트를 다운로드하려면 다음 명령어를 실행합니다.
git clone https://maps-booking.googlesource.com/js-maps-booking-rest-server-v3-skeleton
전체 코드베이스는 다음 두 개의 JavaScript 파일로만 구성됩니다.
- bookingserver.js - 인증을 포함한 HTTP 서버 및 요청 처리 로직
- apiv3methods.js - API v3 인터페이스를 구현하는 메서드
파일을 다운로드한 후 다음 명령어를 실행하여 예약 서버를 시작할 수 있습니다.
node bookingserver.js
스켈레톤은 모든 수신 및 발신 요청을 콘솔에 작성하므로 추적 목적으로 실행을 모니터링할 수 있습니다.
코드 변경이나 디버깅을 위해 IDE가 필요한 경우 Visual Studio Code 또는 원하는 다른 편집기를 사용하면 됩니다. Node.js 환경에서 bookingserver.js를 시작하여 프로젝트를 디버그하고 필요한 위치에 브레이크포인트를 설정합니다.
예약 서버 테스트
Booking 테스트 유틸리티를 다운로드합니다. 설치하려면 README 페이지에 제공된 설치 안내를 따르세요.
테스트를 위해 사용자 인증 정보를 저장할 텍스트 파일을 만들어야 합니다.
사용자 이름과 비밀번호를 한 줄에 입력합니다(예: cred.txt 파일).
username:password
테스트 판매자의 재고 피드의 로컬 사본도 필요합니다.
아래 샘플 명령어에서 어베일러빌리티 피드는 avail.json입니다.
이제 다음 명령어를 사용하여 예약 서버를 테스트할 수 있습니다.
- HealthCheck 메서드 호출 테스트:
bin/bookingClient -server_addr="localhost:8080" -health_check_test=true -credentials_file="./cred.txt"
- CheckAvailability 메서드 호출 테스트:
bin/bookingClient -server_addr="localhost:8080" -check_availability_test=true -availability_feed="./avail.json" -credentials_file="./cred.txt"
- CreateBooking 및 UpdateBooking 메서드 호출을 테스트합니다.
bin/bookingClient -server_addr="localhost:8080" -booking_test=true -availability_feed="./avail.json" -credentials_file="./cred.txt"
자체 예약 서버를 구현할 때는 모든 테스트가 통과하도록(-all_tests=true) 예약 서버에 대해 추가 테스트(예: list_bookings_test, rescheduling_test 등)를 실행해야 할 수 있습니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003eThis is a Node.js-based reference implementation of the API v3 Booking Server for Standard Integration, allowing developers to understand and build their own booking systems.\u003c/p\u003e\n"],["\u003cp\u003eThe server utilizes basic Node.js functionalities and JSON for serialization, offering flexibility for adaptation to various frameworks like Express.js or MEAN.js.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can clone the provided repository, run the server using a simple command, and leverage debugging tools like Visual Studio Code for development.\u003c/p\u003e\n"],["\u003cp\u003eA Booking test utility and sample commands are provided for validating the functionality of the implemented Booking Server using credentials and an Availability feed.\u003c/p\u003e\n"],["\u003cp\u003eFurther testing with additional commands is encouraged to ensure comprehensive coverage and successful integration with the Booking API.\u003c/p\u003e\n"]]],["This document details a Node.js-based reference implementation of an API v3 Booking Server. It uses standard Node.js and JSON serialization. Key actions include: cloning the project via `git`, starting the server with `node bookingserver.js`, and utilizing the Booking test utility for testing. To test, users must create a credentials file and use an Availability feed. Testing commands are provided for HealthCheck, CheckAvailability, CreateBooking, and UpdateBooking. It encourages comprehensive testing.\n"],null,["# Booking Server Skeleton for Node.js\n\nThis is a reference implementation of\n[API v3 Booking Server for Standard Integration](/actions-center/verticals/local-services/e2e/integration-steps/implement-booking-server)\nbased on Node.js\n\n### Prerequisites\n\nRequires an installation of\n\n- [Node.js](https://nodejs.org/)\n\nGetting Started\n---------------\n\nThe Booking Server is implemented using standard Node.js without any\nadditional libraries or frameworks, for illustration purposes. If you are\nusing any other frameworks, you could easily change this implementation to\nExpress.js, MEAN.js, or any other Node.js-based framework of your choice.\n\nThe implementation is also not using protocol buffer libraries, but instead\nrelies on simple JSON serialization and its JSON.parse() and JSON.stringify()\nmethods.\n\nTo download the project, execute the following command: \n\n```javascript\ngit clone https://maps-booking.googlesource.com/js-maps-booking-rest-server-v3-skeleton\n```\n\nThe entire code base consists of only two JavaScript files:\n\n- bookingserver.js - HTTP server and requests handling logic, including authentication\n- apiv3methods.js - methods implementing API v3 interface\n\nAfter you download the files, you can start the Booking Server by running\nthe command: \n\n```javascript\nnode bookingserver.js\n```\n\nThe skeleton writes all incoming and outgoing requests to the console, so you\ncan monitor its execution for tracing purposes.\n\nShould you need an IDE for code changes or debugging, you can use\n[Visual Studio Code](https://code.visualstudio.com/) or any other\neditor of your choice. Debug the project by starting bookingserver.js in the\nNode.js environment and set breakpoints where needed.\n\nTesting your Booking Server\n---------------------------\n\nDownload\n[Booking test utility](https://maps-booking.googlesource.com/maps-booking-v3/). To install it, follow the provided installation\ninstructions in its README page.\n\nFor the tests, you need to create a text file to store your credentials.\nEnter your username and password on a single line, for example, in a file\nnamed cred.txt:\n\nusername:password\n\nYou also need a local copy of an Availability feed for your test merchants.\nIn the samples commands below, the Availability feed is avail.json.\n\nNow, you can test your Booking Server with these commands:\n\n- Test calls to HealthCheck method: \n\n ```javascript\n bin/bookingClient -server_addr=\"localhost:8080\" -health_check_test=true -credentials_file=\"./cred.txt\"\n ```\n- Test calls to CheckAvailability method: \n\n ```javascript\n bin/bookingClient -server_addr=\"localhost:8080\" -check_availability_test=true -availability_feed=\"./avail.json\" -credentials_file=\"./cred.txt\"\n ```\n- Test calls to CreateBooking and UpdateBooking methods: \n\n ```javascript\n bin/bookingClient -server_addr=\"localhost:8080\" -booking_test=true -availability_feed=\"./avail.json\" -credentials_file=\"./cred.txt\"\n ```\n\nAs you are implementing your own Booking Server, you may need to run\nadditional tests against it (e.g. list_bookings_test, rescheduling_test, etc)\nwith the goal of all tests passing (-all_tests=true)."]]