سرور رزرو با استفاده از Node.js استاندارد بدون هیچ گونه کتابخانه یا چارچوب اضافی برای اهداف مصور پیاده سازی می شود. اگر از فریمورکهای دیگری استفاده میکنید، میتوانید به راحتی این پیادهسازی را به Express.js، MEAN.js یا هر فریم ورک مبتنی بر Node.js انتخابی خود تغییر دهید.
این پیادهسازی همچنین از کتابخانههای بافر پروتکل استفاده نمیکند، بلکه به سریالسازی ساده JSON و متدهای JSON.parse() و JSON.stringify() آن متکی است.
کل پایه کد فقط از دو فایل جاوا اسکریپت تشکیل شده است:
bookingserver.js - سرور HTTP و منطق رسیدگی به درخواست ها، از جمله احراز هویت
apiv3methods.js - روش های پیاده سازی رابط API v3
پس از دانلود فایل ها، می توانید با اجرای دستور، سرور رزرو را راه اندازی کنید:
nodebookingserver.js
اسکلت تمام درخواستهای ورودی و خروجی را به کنسول مینویسد، بنابراین میتوانید اجرای آن را برای اهداف ردیابی نظارت کنید.
اگر برای تغییر کد یا اشکال زدایی به IDE نیاز دارید، می توانید از Visual Studio Code یا هر ویرایشگر دیگری که انتخاب می کنید استفاده کنید. پروژه را با شروع bookingserver.js در محیط Node.js اشکال زدایی کنید و در صورت نیاز نقاط شکست را تعیین کنید.
تست سرور رزرو شما
دانلود ابزار آزمون رزرو . برای نصب آن، دستورالعمل های نصب ارائه شده در صفحه README آن را دنبال کنید.
برای تست ها، باید یک فایل متنی برای ذخیره اعتبار خود ایجاد کنید. نام کاربری و رمز عبور خود را در یک خط به عنوان مثال در فایلی به نام cred.txt وارد کنید:
نام کاربری: رمز عبور
شما همچنین به یک نسخه محلی از فید در دسترس بودن برای بازرگانان آزمایشی خود نیاز دارید. در دستورات نمونه زیر، فید Availability avail.json است.
اکنون می توانید سرور رزرو خود را با این دستورات آزمایش کنید:
همانطور که شما در حال پیاده سازی سرور رزرو خود هستید، ممکن است نیاز داشته باشید که تست های بیشتری را بر روی آن اجرا کنید (مثلا list_bookings_test، rescheduling_test، و غیره) با هدف گذراندن همه آزمون ها (-all_tests=true).
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThis is a Node.js-based reference implementation of the API v3 Booking Server for Standard Integration.\u003c/p\u003e\n"],["\u003cp\u003eThe server uses simple JSON serialization and can be easily adapted to various Node.js frameworks.\u003c/p\u003e\n"],["\u003cp\u003eYou can download, run, and debug the server using basic Node.js commands and tools.\u003c/p\u003e\n"],["\u003cp\u003eA provided Booking test utility enables testing HealthCheck, CheckAvailability, CreateBooking, and UpdateBooking methods.\u003c/p\u003e\n"],["\u003cp\u003eFor comprehensive testing, consider running additional tests against your Booking Server implementation.\u003c/p\u003e\n"]]],["This Node.js-based reference implementation of the API v3 Booking Server uses standard Node.js and JSON serialization. To use it, clone the project via `git clone https://maps-booking.googlesource.com/js-maps-booking-rest-server-v3-skeleton`. The server, contained in `bookingserver.js` and `apiv3methods.js`, can be started with `node bookingserver.js`. Testing requires downloading the Booking test utility and creating a credentials file. Test commands for HealthCheck, CheckAvailability, CreateBooking, and UpdateBooking are provided, using sample feed and credentials files.\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/reservations/waitlists/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)."]]