1
0
Fork 0
mirror of synced 2024-06-02 18:44:54 +12:00
budibase/packages/server/src/api/routes/public/tables.js

162 lines
4.3 KiB
JavaScript
Raw Normal View History

const controller = require("../../controllers/public/tables")
const Endpoint = require("./utils/Endpoint")
2022-02-25 01:03:46 +13:00
const { tableValidator, nameValidator } = require("../utils/validators")
2022-02-18 07:58:09 +13:00
const read = [],
write = []
/**
* @openapi
* /tables/search:
* post:
* summary: Search internal and external tables based on their name.
* tags:
* - tables
2022-02-19 07:06:58 +13:00
* parameters:
* - $ref: '#/components/parameters/appId'
* requestBody:
2022-02-23 03:28:57 +13:00
* required: true
2022-02-19 07:06:58 +13:00
* content:
* application/json:
* schema:
2022-02-23 03:28:57 +13:00
* $ref: '#/components/schemas/nameSearch'
* responses:
* 200:
* description: Returns the found tables, based on the search parameters.
* content:
* application/json:
* schema:
* type: object
* properties:
* applications:
* type: array
* items:
* $ref: '#/components/schemas/table'
* examples:
* tables:
* $ref: '#/components/examples/tables'
*/
2022-02-25 01:03:46 +13:00
read.push(
new Endpoint("post", "/tables/search", controller.search).addMiddleware(
nameValidator()
)
)
/**
* @openapi
* /tables:
* post:
* summary: Create a new table.
* tags:
* - tables
2022-02-19 07:06:58 +13:00
* parameters:
* - $ref: '#/components/parameters/appId'
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/table'
* examples:
* table:
* $ref: '#/components/examples/table'
* responses:
* 200:
* description: Returns the created table, including the ID which has been generated for it. This can be
* internal or external data sources.
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/tableOutput'
* examples:
* table:
* $ref: '#/components/examples/table'
*/
write.push(
new Endpoint("post", "/tables", controller.create).addMiddleware(
tableValidator()
)
)
/**
* @openapi
2022-02-23 03:28:57 +13:00
* /tables/{tableId}:
* put:
2022-02-23 03:28:57 +13:00
* summary: Update the specified table.
* tags:
* - tables
* parameters:
* - $ref: '#/components/parameters/tableId'
* - $ref: '#/components/parameters/appId'
2022-02-19 07:06:58 +13:00
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/table'
* examples:
* table:
* $ref: '#/components/examples/table'
* responses:
* 200:
* description: Returns the updated table.
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/tableOutput'
* examples:
* table:
* $ref: '#/components/examples/table'
*/
write.push(
new Endpoint("put", "/tables/:tableId", controller.update).addMiddleware(
tableValidator()
)
)
/**
* @openapi
* /tables/{tableId}:
* delete:
* summary: Delete a single table and all of its data.
* tags:
* - tables
* parameters:
* - $ref: '#/components/parameters/tableId'
* - $ref: '#/components/parameters/appId'
* responses:
* 200:
* description: Returns the deleted table.
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/tableOutput'
* examples:
* table:
* $ref: '#/components/examples/table'
*/
write.push(new Endpoint("delete", "/tables/:tableId", controller.delete))
2022-02-18 07:58:09 +13:00
/**
* @openapi
* /tables/{tableId}:
* get:
* summary: Gets a single table by its ID.
* tags:
* - tables
* parameters:
* - $ref: '#/components/parameters/tableId'
* - $ref: '#/components/parameters/appId'
* responses:
* 200:
* description: Returns the retrieved table.
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/tableOutput'
* examples:
* table:
* $ref: '#/components/examples/table'
*/
read.push(new Endpoint("get", "/tables/:tableId", controller.read))
module.exports = { read, write }