"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tokenRouter = void 0;
const tslib_1 = require("tslib");
const express_1 = tslib_1.__importDefault(require("express"));
const video_tokens_manager_1 = require("../../../lib/video-tokens-manager");
const middlewares_1 = require("../../../middlewares");
const tokenRouter = express_1.default.Router();
exports.tokenRouter = tokenRouter;
tokenRouter.post('/:id/token', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)((0, middlewares_1.videosCustomGetValidator)('only-video')), generateToken);
function generateToken(req, res) {
    const video = res.locals.onlyVideo;
    const { token, expires } = video_tokens_manager_1.VideoTokensManager.Instance.create(video.uuid);
    return res.json({
        files: {
            token,
            expires
        }
    });
}
//# sourceMappingURL=token.js.map