📁 Changed TDrive root folder (#16)

📁 Changed TDrive root folder
This commit is contained in:
Montassar Ghanmy
2023-04-11 10:04:29 +01:00
committed by GitHub
parent 3b3f67af07
commit e0615fa867
10548 changed files with 48 additions and 48 deletions
@@ -0,0 +1,100 @@
import { FastifyInstance, FastifyPluginCallback } from "fastify";
import { DocumentsController } from "./controllers";
import { createDocumentSchema, createVersionSchema } from "./schemas";
const baseUrl = "/companies/:company_id";
const serviceUrl = `${baseUrl}/item`;
const routes: FastifyPluginCallback = (fastify: FastifyInstance, _options, next) => {
const documentsController = new DocumentsController();
fastify.route({
method: "GET",
url: `${serviceUrl}`,
preValidation: [fastify.authenticateOptional],
handler: documentsController.listRootFolder.bind(documentsController),
});
fastify.route({
method: "GET",
url: `${serviceUrl}/:id`,
preValidation: [fastify.authenticateOptional],
handler: documentsController.get.bind(documentsController),
});
fastify.route({
method: "POST",
url: serviceUrl,
preValidation: [fastify.authenticateOptional],
schema: createDocumentSchema,
handler: documentsController.create.bind(documentsController),
});
fastify.route({
method: "POST",
url: `${serviceUrl}/:id`,
preValidation: [fastify.authenticateOptional],
handler: documentsController.update.bind(documentsController),
});
fastify.route({
method: "DELETE",
url: `${serviceUrl}/:id`,
preValidation: [fastify.authenticateOptional],
handler: documentsController.delete.bind(documentsController),
});
fastify.route({
method: "POST",
url: `${serviceUrl}/:id/version`,
preValidation: [fastify.authenticateOptional],
schema: createVersionSchema,
handler: documentsController.createVersion.bind(documentsController),
});
fastify.route({
method: "GET",
url: `${serviceUrl}/download/token`,
preValidation: [fastify.authenticateOptional],
handler: documentsController.downloadGetToken.bind(documentsController),
});
fastify.route({
method: "GET",
url: `${serviceUrl}/:id/download`,
preValidation: [fastify.authenticateOptional],
handler: documentsController.download.bind(documentsController),
});
fastify.route({
method: "GET",
url: `${serviceUrl}/download/zip`,
preValidation: [fastify.authenticateOptional],
handler: documentsController.downloadZip.bind(documentsController),
});
fastify.route({
method: "POST",
url: `${baseUrl}/search`,
preValidation: [fastify.authenticate],
handler: documentsController.search.bind(documentsController),
});
fastify.route({
method: "GET",
url: `${baseUrl}/tabs/:tab_id`,
preValidation: [fastify.authenticate],
handler: documentsController.getTab.bind(documentsController),
});
fastify.route({
method: "POST",
url: `${baseUrl}/tabs/:tab_id`,
preValidation: [fastify.authenticate],
handler: documentsController.setTab.bind(documentsController),
});
return next();
};
export default routes;