feat: implement create functionality for WapServers across server, sysadmin, and CLI layers
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
PaginateWapServerResults,
|
||||
SysAdminCreateWapServerParams,
|
||||
SysAdminDeleteWapServerRequest,
|
||||
SysAdminDeleteWapServerResult,
|
||||
SysAdminAuditWapServerParams,
|
||||
@@ -55,6 +56,27 @@ const getErrorDesc = (error: unknown): string => {
|
||||
return fallback || "Unknown error while auditing WAP server";
|
||||
};
|
||||
|
||||
@Route("sysadmin/wapserver/create")
|
||||
export class SysAdminWapServerCreateController extends Controller {
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
@SuccessResponse(200, "Done")
|
||||
@Post()
|
||||
@Middlewares(sysAdminAuthMiddleware)
|
||||
public async sysAdminCreateWapServer(
|
||||
@Body() requestBody: SysAdminCreateWapServerParams,
|
||||
): Promise<IWapServer | ApiValidationError> {
|
||||
try {
|
||||
const { payload, ...cleanRequestBody } = requestBody as any;
|
||||
const result = await new SA_WapServerService().sysAdminCreateWapServer(cleanRequestBody);
|
||||
this.setStatus(200);
|
||||
return result;
|
||||
} catch (e) {
|
||||
this.setStatus(500);
|
||||
return new ApiValidationError(500, getErrorDesc(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Route("sysadmin/wapserver/get")
|
||||
export class SysAdminWapServerGetController extends Controller {
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { connect } from "mongoose";
|
||||
|
||||
import {
|
||||
CreateWapServerParams,
|
||||
PaginateWapServerParams,
|
||||
PaginateWapServerResults,
|
||||
SysAdminDeleteWapServerParams,
|
||||
@@ -23,6 +24,11 @@ export class SA_WapServerService {
|
||||
return await WapServerList.sysAdminGetWapServers(data);
|
||||
}
|
||||
|
||||
public async sysAdminCreateWapServer(data: CreateWapServerParams) {
|
||||
await connect(`${process.env.DATABASE_CONNECTION}`);
|
||||
return await WapServerList.sysAdminCreateWapServer(data);
|
||||
}
|
||||
|
||||
public async sysAdminUpdateWapServer(data: UpdateWapServerParams) {
|
||||
await connect(`${process.env.DATABASE_CONNECTION}`);
|
||||
return await WapServerList.sysAdminUpdateWapServer(data);
|
||||
|
||||
Reference in New Issue
Block a user