✨ created main services and controller for the IUser
This commit is contained in:
parent
76646bea0a
commit
961a8b991d
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "tezoslink",
|
||||
"name": "lecoffre",
|
||||
"version": "1.0.0",
|
||||
"description": "tezosLink project",
|
||||
"description": "lecoffre project",
|
||||
"_moduleAliases": {
|
||||
"@App": "./dist/app",
|
||||
"@Api": "./dist/app/api",
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { type Response, type Request } from "express";
|
||||
import { Controller, Get } from "@ControllerPattern/index";
|
||||
// import { IsNotEmpty, IsString, IsUUID } from "class-validator";
|
||||
import { Controller, Get, Post, Put } from "@ControllerPattern/index";
|
||||
import { Service } from "typedi";
|
||||
import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import UsersService from "@Services/UsersService/UsersService";
|
||||
// import { IsNotEmpty, IsString, IsUUID } from "class-validator";
|
||||
|
||||
// class Params {
|
||||
// @IsString()
|
||||
@ -20,15 +20,59 @@ export default class UserController extends ApiController {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Get all users
|
||||
* @returns IUser[] list of users
|
||||
*/
|
||||
@Get("/api/users")
|
||||
protected async get(req: Request, response: Response) {
|
||||
console.log("UserController > get > response");
|
||||
// request: Request
|
||||
// const query = this.buildQueryAsObject<Partial<TokenSupportEntity>>(request);
|
||||
try {
|
||||
// await validateOrReject(QueryService.createFrom<Partial<TokenSupportEntity>>(query), {
|
||||
// forbidUnknownValues: true,
|
||||
// });
|
||||
// TODO
|
||||
} catch (error) {
|
||||
this.httpBadRequest(response, error);
|
||||
return;
|
||||
}
|
||||
this.httpSuccess(response, await this.userService.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Create a new user
|
||||
* @returns IUser created
|
||||
*/
|
||||
@Post("/api/users")
|
||||
protected async post(req: Request, response: Response) {
|
||||
try {
|
||||
// TODO
|
||||
} catch (error) {
|
||||
this.httpBadRequest(response, error);
|
||||
return;
|
||||
}
|
||||
this.httpSuccess(response, await this.userService.create());
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Modify a specific user by uid
|
||||
* @returns IUser modified
|
||||
*/
|
||||
@Put("/api/users/:uid")
|
||||
protected async put(req: Request, response: Response) {
|
||||
try {
|
||||
// TODO
|
||||
} catch (error) {
|
||||
this.httpBadRequest(response, error);
|
||||
return;
|
||||
}
|
||||
this.httpSuccess(response, await this.userService.create());
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Get a specific user by uid
|
||||
* @returns IUser
|
||||
*/
|
||||
@Get("/api/users/:uid")
|
||||
protected async getOneByUid(req: Request, response: Response) {
|
||||
try {
|
||||
// TODO
|
||||
} catch (error) {
|
||||
this.httpBadRequest(response, error);
|
||||
return;
|
||||
|
@ -9,17 +9,19 @@ export default class UsersService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get all users
|
||||
* @returns : T
|
||||
* @throws {Error} If project cannot be created
|
||||
* @param : projectEntity: Partial<ProjectEntity>
|
||||
*/
|
||||
public async getByUid(uuid: string) {
|
||||
public async get() {
|
||||
// const user = await this.usersRepository.findOne(uuid);
|
||||
// if (!user) Promise.reject(new Error("Cannot get user by uuid"));
|
||||
return "User/getByUid > Not implemented yet";
|
||||
return { response: "/api/users > GET : All users > Not implemented yet" };
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a new user
|
||||
* @returns : T
|
||||
* @throws {Error} If project cannot be created
|
||||
* @param : projectEntity: Partial<ProjectEntity>
|
||||
@ -27,6 +29,30 @@ export default class UsersService extends BaseService {
|
||||
public async create() {
|
||||
// const project = await this.projectRepository.create(projectEntity);
|
||||
// if (!project) Promise.reject(new Error("Cannot create project"));
|
||||
// return project;
|
||||
return { response: "/api/users > POST : Create User > Not implemented yet" };
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a new user
|
||||
* @returns : T
|
||||
* @throws {Error} If project cannot be created
|
||||
* @param : projectEntity: Partial<ProjectEntity>
|
||||
*/
|
||||
public async put() {
|
||||
// const project = await this.projectRepository.create(projectEntity);
|
||||
// if (!project) Promise.reject(new Error("Cannot create project"));
|
||||
return { response: "/api/users > POST : Create User > Not implemented yet" };
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a user by uid
|
||||
* @returns : T
|
||||
* @throws {Error} If project cannot be created
|
||||
* @param : projectEntity: Partial<ProjectEntity>
|
||||
*/
|
||||
public async getByUid(uuid: string) {
|
||||
// const user = await this.usersRepository.findOne(uuid);
|
||||
// if (!user) Promise.reject(new Error("Cannot get user by uuid"));
|
||||
return { response: "/api/users/:uuid > GET : User by uid > Not implemented yet" };
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user