feat: add container page api
This commit is contained in:
		| @@ -1,3 +1,4 @@ | ||||
| import { CustomError } from '@abearxiong/router'; | ||||
| import { app } from '../../app.ts'; | ||||
| import { ContainerModel, ContainerData, Container } from './models/index.ts'; | ||||
|  | ||||
| @@ -13,6 +14,21 @@ list.run = async (ctx) => { | ||||
|  | ||||
| list.addTo(app); | ||||
|  | ||||
| app | ||||
|   .route({ | ||||
|     path: 'container', | ||||
|     key: 'get', | ||||
|   }) | ||||
|   .define(async (ctx) => { | ||||
|     const id = ctx.query.id; | ||||
|     if (!id) { | ||||
|       throw new CustomError('id is required'); | ||||
|     } | ||||
|     ctx.body = await ContainerModel.findByPk(id); | ||||
|     return ctx; | ||||
|   }) | ||||
|   .addTo(app); | ||||
|  | ||||
| const add = app.route({ | ||||
|   path: 'container', | ||||
|   key: 'update', | ||||
| @@ -46,8 +62,7 @@ add.run = async (ctx) => { | ||||
|       containerModel.save(); | ||||
|     } | ||||
|   } else { | ||||
|     try{ | ||||
|  | ||||
|     try { | ||||
|       containerModel = await ContainerModel.create({ | ||||
|         ...container, | ||||
|       }); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user