UNPKG

@sync-in/server

Version:

The secure, open-source platform for file storage, sharing, collaboration, and sync

173 lines (172 loc) 7.75 kB
/* * Copyright (C) 2012-2025 Johan Legrand <johan.legrand@sync-in.com> * This file is part of Sync-in | The open source file sync and share solution * See the LICENSE file for licensing details */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "WebDAVController", { enumerable: true, get: function() { return WebDAVController; } }); const _common = require("@nestjs/common"); const _fastify = require("fastify"); const _applicationsconstants = require("../applications.constants"); const _spaces = require("../spaces/constants/spaces"); const _spaceguard = require("../spaces/guards/space.guard"); const _routes = require("./constants/routes"); const _webdavcontextdecorator = require("./decorators/webdav-context.decorator"); const _webdavinterface = require("./interfaces/webdav.interface"); const _webdavmethodsservice = require("./services/webdav-methods.service"); function _ts_decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function _ts_metadata(k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); } function _ts_param(paramIndex, decorator) { return function(target, key) { decorator(target, key, paramIndex); }; } let WebDAVController = class WebDAVController { serverOptions() { // OPTIONS method is handled in the `DavProtocolGuard` return; } serverPropFind(req, res) { return this.webdavMethods.propfind(req, res, _routes.WEBDAV_NS.SERVER); } webdavOptions() { // OPTIONS method is handled in the `DavProtocolGuard` return; } async webdavPropfind(req, res) { return this.webdavMethods.propfind(req, res, _routes.WEBDAV_NS.WEBDAV); } repositoriesOptions() { // OPTIONS method is handled in the `DavProtocolGuard` return; } async repositoriesPropfind(req, res, repository) { return this.webdavMethods.propfind(req, res, repository); } async files(req, res) { // OPTIONS method is handled in the `DavProtocolGuard` switch(req.method){ case _applicationsconstants.HTTP_METHOD.PROPFIND: return this.webdavMethods.propfind(req, res, _spaces.SPACE_REPOSITORY.FILES); case _applicationsconstants.HTTP_METHOD.HEAD: case _applicationsconstants.HTTP_METHOD.GET: return this.webdavMethods.headOrGet(req, res, _spaces.SPACE_REPOSITORY.FILES); case _applicationsconstants.HTTP_METHOD.PUT: return this.webdavMethods.put(req, res); case _applicationsconstants.HTTP_METHOD.DELETE: return this.webdavMethods.delete(req, res); case _applicationsconstants.HTTP_METHOD.LOCK: return this.webdavMethods.lock(req, res); case _applicationsconstants.HTTP_METHOD.UNLOCK: return this.webdavMethods.unlock(req, res); case _applicationsconstants.HTTP_METHOD.PROPPATCH: return this.webdavMethods.proppatch(req, res); case _applicationsconstants.HTTP_METHOD.MKCOL: return this.webdavMethods.mkcol(req, res); case _applicationsconstants.HTTP_METHOD.COPY: case _applicationsconstants.HTTP_METHOD.MOVE: return this.webdavMethods.copyMove(req, res); default: return res.status(_common.HttpStatus.METHOD_NOT_ALLOWED).send(); } } constructor(webdavMethods){ this.webdavMethods = webdavMethods; } }; _ts_decorate([ (0, _common.Options)(), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", []), _ts_metadata("design:returntype", void 0) ], WebDAVController.prototype, "serverOptions", null); _ts_decorate([ (0, _common.Propfind)(), _ts_param(0, (0, _common.Req)()), _ts_param(1, (0, _common.Res)({ passthrough: true })), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", [ typeof _webdavinterface.FastifyDAVRequest === "undefined" ? Object : _webdavinterface.FastifyDAVRequest, typeof _fastify.FastifyReply === "undefined" ? Object : _fastify.FastifyReply ]), _ts_metadata("design:returntype", void 0) ], WebDAVController.prototype, "serverPropFind", null); _ts_decorate([ (0, _common.Options)(_routes.WEBDAV_BASE_PATH), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", []), _ts_metadata("design:returntype", void 0) ], WebDAVController.prototype, "webdavOptions", null); _ts_decorate([ (0, _common.Propfind)(_routes.WEBDAV_BASE_PATH), _ts_param(0, (0, _common.Req)()), _ts_param(1, (0, _common.Res)({ passthrough: true })), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", [ typeof _webdavinterface.FastifyDAVRequest === "undefined" ? Object : _webdavinterface.FastifyDAVRequest, typeof _fastify.FastifyReply === "undefined" ? Object : _fastify.FastifyReply ]), _ts_metadata("design:returntype", Promise) ], WebDAVController.prototype, "webdavPropfind", null); _ts_decorate([ (0, _common.Options)(`${_routes.WEBDAV_BASE_PATH}/:repository(^(${_routes.WEBDAV_NS.SPACES}|${_routes.WEBDAV_NS.TRASH})$)`), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", []), _ts_metadata("design:returntype", void 0) ], WebDAVController.prototype, "repositoriesOptions", null); _ts_decorate([ (0, _common.Propfind)(`${_routes.WEBDAV_BASE_PATH}/:repository(^(${_routes.WEBDAV_NS.SPACES}|${_routes.WEBDAV_NS.TRASH})$)`), _ts_param(0, (0, _common.Req)()), _ts_param(1, (0, _common.Res)({ passthrough: true })), _ts_param(2, (0, _common.Param)('repository')), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", [ typeof _webdavinterface.FastifyDAVRequest === "undefined" ? Object : _webdavinterface.FastifyDAVRequest, typeof _fastify.FastifyReply === "undefined" ? Object : _fastify.FastifyReply, String ]), _ts_metadata("design:returntype", Promise) ], WebDAVController.prototype, "repositoriesPropfind", null); _ts_decorate([ (0, _common.All)(`${_routes.WEBDAV_BASE_PATH}/*`), (0, _common.UseGuards)(_spaceguard.SpaceGuard), _ts_param(0, (0, _common.Req)()), _ts_param(1, (0, _common.Res)({ passthrough: true })), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", [ typeof _webdavinterface.FastifyDAVRequest === "undefined" ? Object : _webdavinterface.FastifyDAVRequest, typeof _fastify.FastifyReply === "undefined" ? Object : _fastify.FastifyReply ]), _ts_metadata("design:returntype", Promise) ], WebDAVController.prototype, "files", null); WebDAVController = _ts_decorate([ (0, _common.Controller)(), (0, _webdavcontextdecorator.WebDAVEnvironment)(), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", [ typeof _webdavmethodsservice.WebDAVMethods === "undefined" ? Object : _webdavmethodsservice.WebDAVMethods ]) ], WebDAVController); //# sourceMappingURL=webdav.controller.js.map