@di-zed/yandex-smart-home
Version:
The Yandex Smart Home skills for the different device types.
71 lines (70 loc) • 2.43 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @author DiZed Team
* @copyright Copyright (c) DiZed Team (https://github.com/di-zed/)
*/
const express_1 = require("express");
const catchAsync_1 = __importDefault(require("../../errors/catchAsync"));
const authController_1 = __importDefault(require("../../controllers/authController"));
const userController_1 = __importDefault(require("../../controllers/rest/userController"));
/**
* REST User Routes.
*/
class UserRoutes {
/**
* Routes Constructor.
*/
constructor() {
/**
* REST User Controller.
*
* @protected
*/
this.controller = new userController_1.default();
/**
* Router.
*
* @protected
*/
this.router = (0, express_1.Router)();
this.initRoutes();
}
/**
* Routes Initialization.
*
* @returns void
* @protected
*/
initRoutes() {
const authController = new authController_1.default();
// Notification of unlinked accounts.
this.router
.route('/unlink')
.post((0, catchAsync_1.default)(authController.protect.bind(authController)), (0, catchAsync_1.default)(this.controller.unlink.bind(this.controller)));
// Information about user devices.
this.router
.route('/devices')
.get((0, catchAsync_1.default)(authController.protect.bind(authController)), (0, catchAsync_1.default)(this.controller.devices.bind(this.controller)));
// Information about the states of user devices.
this.router
.route('/devices/query')
.post((0, catchAsync_1.default)(authController.protect.bind(authController)), (0, catchAsync_1.default)(this.controller.devicesQuery.bind(this.controller)));
// Change device state.
this.router
.route('/devices/action')
.post((0, catchAsync_1.default)(authController.protect.bind(authController)), (0, catchAsync_1.default)(this.controller.devicesAction.bind(this.controller)));
}
/**
* Get Router.
*
* @returns Router
*/
getRouter() {
return this.router;
}
}
exports.default = new UserRoutes().getRouter();