@windingtree/wt-read-api
Version:
API to interact with the Winding Tree platform
36 lines (29 loc) • 2.47 kB
JavaScript
const express = require('express');
const {
injectWtLibs,
validateHotelAddress,
resolveHotel,
validateOrgJsonHash,
handleOnChainErrors,
handleDataFetchingErrors,
} = require('../middlewares');
const hotelsController = require('../controllers/hotels');
const roomTypesController = require('../controllers/room-types');
const ratePlansController = require('../controllers/rate-plans');
const availabilityController = require('../controllers/availability');
const hotelsRouter = express.Router({
strict: true,
});
hotelsRouter.get('/hotels', injectWtLibs, hotelsController.findAll, handleOnChainErrors);
hotelsRouter.get('/hotels/:hotelAddress', injectWtLibs, validateHotelAddress, resolveHotel, validateOrgJsonHash, hotelsController.find, handleOnChainErrors);
hotelsRouter.get('/hotels/:hotelAddress/meta', injectWtLibs, validateHotelAddress, resolveHotel, validateOrgJsonHash, hotelsController.meta, handleOnChainErrors);
hotelsRouter.get('/hotels/:hotelAddress/availability', injectWtLibs, validateHotelAddress, resolveHotel, validateOrgJsonHash, availabilityController.findAll, handleOnChainErrors, handleDataFetchingErrors);
hotelsRouter.get('/hotels/:hotelAddress/roomTypes', injectWtLibs, validateHotelAddress, resolveHotel, validateOrgJsonHash, roomTypesController.findAll, handleOnChainErrors, handleDataFetchingErrors);
hotelsRouter.get('/hotels/:hotelAddress/roomTypes/:roomTypeId', injectWtLibs, validateHotelAddress, resolveHotel, validateOrgJsonHash, roomTypesController.find, handleOnChainErrors, handleDataFetchingErrors);
hotelsRouter.get('/hotels/:hotelAddress/roomTypes/:roomTypeId/ratePlans', injectWtLibs, validateHotelAddress, resolveHotel, validateOrgJsonHash, roomTypesController.findRatePlans, handleOnChainErrors, handleDataFetchingErrors);
hotelsRouter.get('/hotels/:hotelAddress/roomTypes/:roomTypeId/availability', injectWtLibs, validateHotelAddress, resolveHotel, validateOrgJsonHash, roomTypesController.findAvailability, handleOnChainErrors, handleDataFetchingErrors);
hotelsRouter.get('/hotels/:hotelAddress/ratePlans', injectWtLibs, validateHotelAddress, resolveHotel, validateOrgJsonHash, ratePlansController.findAll, handleOnChainErrors, handleDataFetchingErrors);
hotelsRouter.get('/hotels/:hotelAddress/ratePlans/:ratePlanId', injectWtLibs, validateHotelAddress, resolveHotel, validateOrgJsonHash, ratePlansController.find, handleOnChainErrors, handleDataFetchingErrors);
module.exports = {
hotelsRouter,
};