2022-02-18 07:58:09 +13:00
|
|
|
const Router = require("@koa/router")
|
2022-02-19 04:47:15 +13:00
|
|
|
const controller = require("../../controllers/public/tables")
|
2022-02-18 07:58:09 +13:00
|
|
|
|
|
|
|
const router = Router()
|
2022-02-19 06:44:08 +13:00
|
|
|
|
2022-02-19 04:47:15 +13:00
|
|
|
/**
|
|
|
|
* @openapi
|
2022-02-19 06:44:08 +13:00
|
|
|
* /tables/search:
|
2022-02-19 04:47:15 +13:00
|
|
|
* post:
|
2022-02-19 06:44:08 +13:00
|
|
|
* summary: Search internal and external tables based on their name.
|
2022-02-19 04:47:15 +13:00
|
|
|
* tags:
|
|
|
|
* - tables
|
2022-02-19 07:06:58 +13:00
|
|
|
* parameters:
|
|
|
|
* - $ref: '#/components/parameters/appId'
|
2022-02-19 06:44:08 +13:00
|
|
|
* requestBody:
|
2022-02-19 07:06:58 +13:00
|
|
|
* content:
|
|
|
|
* application/json:
|
|
|
|
* schema:
|
|
|
|
* type: object
|
|
|
|
* properties:
|
|
|
|
* name:
|
|
|
|
* type: string
|
2022-02-22 05:37:02 +13:00
|
|
|
* description: The name of the table, this is a case insensitive search using the provided
|
|
|
|
* name as a starts with search.
|
2022-02-19 04:47:15 +13:00
|
|
|
* responses:
|
|
|
|
* 200:
|
2022-02-19 06:44:08 +13:00
|
|
|
* description: Returns the found tables, based on the search parameters.
|
2022-02-19 04:47:15 +13:00
|
|
|
* content:
|
|
|
|
* application/json:
|
|
|
|
* schema:
|
2022-02-23 03:10:01 +13:00
|
|
|
* type: object
|
|
|
|
* properties:
|
|
|
|
* applications:
|
|
|
|
* type: array
|
|
|
|
* items:
|
|
|
|
* $ref: '#/components/schemas/table'
|
2022-02-19 04:47:15 +13:00
|
|
|
* examples:
|
2022-02-19 06:44:08 +13:00
|
|
|
* tables:
|
|
|
|
* $ref: '#/components/examples/tables'
|
2022-02-19 04:47:15 +13:00
|
|
|
*/
|
2022-02-19 06:44:08 +13:00
|
|
|
router.post("/tables/search", controller.search)
|
2022-02-19 04:47:15 +13:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @openapi
|
2022-02-19 06:44:08 +13:00
|
|
|
* /tables:
|
|
|
|
* post:
|
|
|
|
* summary: Create a new table.
|
2022-02-19 04:47:15 +13:00
|
|
|
* 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'
|
2022-02-19 04:47:15 +13:00
|
|
|
* responses:
|
|
|
|
* 200:
|
2022-02-19 06:44:08 +13:00
|
|
|
* description: Returns the created table, including the ID which has been generated for it. This can be
|
|
|
|
* internal or external data sources.
|
2022-02-19 04:47:15 +13:00
|
|
|
* content:
|
|
|
|
* application/json:
|
|
|
|
* schema:
|
2022-02-23 03:10:01 +13:00
|
|
|
* $ref: '#/components/schemas/tableOutput'
|
2022-02-19 04:47:15 +13:00
|
|
|
* examples:
|
2022-02-19 06:44:08 +13:00
|
|
|
* table:
|
|
|
|
* $ref: '#/components/examples/table'
|
2022-02-19 04:47:15 +13:00
|
|
|
*/
|
2022-02-19 06:44:08 +13:00
|
|
|
router.post("/tables", controller.create)
|
2022-02-19 04:47:15 +13:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @openapi
|
2022-02-19 06:44:08 +13:00
|
|
|
* /tables/:tableId:
|
|
|
|
* put:
|
|
|
|
* summary: Update the specified table. This can be for internal or external tables.
|
2022-02-19 04:47:15 +13:00
|
|
|
* tags:
|
|
|
|
* - tables
|
|
|
|
* parameters:
|
|
|
|
* - $ref: '#/components/parameters/tableId'
|
2022-02-19 06:44:08 +13:00
|
|
|
* - $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'
|
2022-02-19 04:47:15 +13:00
|
|
|
* responses:
|
|
|
|
* 200:
|
2022-02-19 06:44:08 +13:00
|
|
|
* description: Returns the updated table.
|
2022-02-19 04:47:15 +13:00
|
|
|
* content:
|
|
|
|
* application/json:
|
|
|
|
* schema:
|
2022-02-23 03:10:01 +13:00
|
|
|
* $ref: '#/components/schemas/tableOutput'
|
2022-02-19 04:47:15 +13:00
|
|
|
* examples:
|
2022-02-19 06:44:08 +13:00
|
|
|
* table:
|
2022-02-23 03:10:01 +13:00
|
|
|
* $ref: '#/components/examples/table'
|
2022-02-19 04:47:15 +13:00
|
|
|
*/
|
2022-02-19 06:44:08 +13:00
|
|
|
router.put("/tables/:tableId", controller.update)
|
2022-02-19 04:47:15 +13:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @openapi
|
2022-02-19 06:44:08 +13:00
|
|
|
* /tables/{tableId}:
|
|
|
|
* delete:
|
|
|
|
* summary: Delete a single table and all of its data.
|
2022-02-19 04:47:15 +13:00
|
|
|
* tags:
|
2022-02-19 06:44:08 +13:00
|
|
|
* - tables
|
2022-02-19 04:47:15 +13:00
|
|
|
* parameters:
|
|
|
|
* - $ref: '#/components/parameters/tableId'
|
2022-02-19 06:44:08 +13:00
|
|
|
* - $ref: '#/components/parameters/appId'
|
2022-02-19 04:47:15 +13:00
|
|
|
* responses:
|
|
|
|
* 200:
|
2022-02-19 06:44:08 +13:00
|
|
|
* description: Returns the deleted table.
|
2022-02-19 04:47:15 +13:00
|
|
|
* content:
|
|
|
|
* application/json:
|
|
|
|
* schema:
|
2022-02-23 03:10:01 +13:00
|
|
|
* $ref: '#/components/schemas/tableOutput'
|
2022-02-19 04:47:15 +13:00
|
|
|
* examples:
|
2022-02-19 06:44:08 +13:00
|
|
|
* table:
|
|
|
|
* $ref: '#/components/examples/table'
|
2022-02-19 04:47:15 +13:00
|
|
|
*/
|
|
|
|
router.delete("/tables/:tableId", controller.delete)
|
2022-02-18 07:58:09 +13:00
|
|
|
|
2022-02-23 03:10:01 +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'
|
|
|
|
*/
|
|
|
|
router.get("/tables/:tableId", controller.read)
|
|
|
|
|
2022-02-18 07:58:09 +13:00
|
|
|
module.exports = router
|