continue the journey

This commit is contained in:
batche
2022-10-21 16:55:39 +02:00
parent a175ef7162
commit b12db3e912
14 changed files with 67 additions and 38 deletions

View File

@@ -10,13 +10,12 @@ exports.AppModule = void 0;
const common_1 = require("@nestjs/common");
const app_controller_1 = require("./app.controller");
const app_service_1 = require("./app.service");
const auth_module_1 = require("./auth/auth.module");
const users_module_1 = require("./users/users.module");
let AppModule = class AppModule {
};
AppModule = __decorate([
(0, common_1.Module)({
imports: [auth_module_1.AuthModule, users_module_1.UsersModule],
imports: [users_module_1.UsersModule],
controllers: [app_controller_1.AppController],
providers: [app_service_1.AppService],
})

View File

@@ -1 +1 @@
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,+CAA2C;AAC3C,oDAAgD;AAChD,uDAAmD;AAO5C,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IALrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,wBAAU,EAAE,0BAAW,CAAC;QAClC,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"}
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,+CAA2C;AAE3C,uDAAmD;AAO5C,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IALrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,0BAAW,CAAC;QACtB,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"}

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
export declare class User {
userId: number;
userId: string;
username: string;
password: string;
}

View File

@@ -2,9 +2,9 @@ import { UsersService } from './users.service';
export declare class UsersController {
private readonly usersService;
constructor(usersService: UsersService);
findAll(query: any): string;
findOne(id: string): string;
create(body: any): any;
findAll(query: any): import("./entities/user.entity").User[];
findOne(id: string): import("./entities/user.entity").User;
create(body: any): string;
update(id: string, body: any): string;
remove(id: string): string;
}

View File

@@ -20,20 +20,19 @@ let UsersController = class UsersController {
this.usersService = usersService;
}
findAll(query) {
const { limit, offset } = query;
return `This action returns all users. The limits is ${limit} and the offset is ${offset}`;
return this.usersService.findAll();
}
findOne(id) {
return 'This action returns a single user whose id is ' + id;
return this.usersService.findOne(id);
}
create(body) {
return body;
return this.usersService.create(body);
}
update(id, body) {
return 'The user whose id is ' + id + ' has been updated';
return this.usersService.update(id, body);
}
remove(id) {
return 'The user whose id is ' + id + ' has been deleted';
return this.usersService.remove(id);
}
};
__decorate([

View File

@@ -1 +1 @@
{"version":3,"file":"users.controller.js","sourceRoot":"","sources":["../../src/users/users.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAGwB;AAExB,mDAA+C;AAGxC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC3B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAG3D,OAAO,CAAU,KAAK;QACrB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAChC,OAAO,gDAAgD,KAAK,sBAAsB,MAAM,EAAE,CAAC;IAC5F,CAAC;IAGD,OAAO,CAAc,EAAU;QAC9B,OAAO,iDAAiD,GAAG,EAAE,CAAC;IAC/D,CAAC;IAID,MAAM,CAAS,IAAI;QAClB,OAAO,IAAI,CAAC;IACb,CAAC;IAGD,MAAM,CAAc,EAAU,EAAU,IAAI;QAC3C,OAAO,uBAAuB,GAAG,EAAE,GAAG,mBAAmB,CAAC;IAC3D,CAAC;IAGD,MAAM,CAAc,EAAU;QAC7B,OAAO,uBA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AAc,EAAU,EAAU,IAAI;QAC3C,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAGD,MAAM,CAAc,EAAU;QAC7B,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;CACD,CAAA;AA1BA;IAAC,IAAA,YAAG,GAAE;IACG,WAAA,IAAA,cAAK,GAAE,CAAA;;;;8CAGf;AAED;IAAC,IAAA,YAAG,EAAC,KAAK,CAAC;IACF,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;8CAEnB;AAED;IAAC,IAAA,aAAI,GAAE;IACN,IAAA,iBAAQ,EAAC,mBAAU,CAAC,IAAI,CAAC;IAClB,WAAA,IAAA,aAAI,GAAE,CAAA;;;;6CAEb;AAED;IAAC,IAAA,cAAK,EAAC,KAAK,CAAC;IACL,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,aAAI,GAAE,CAAA;;;;6CAEtC;AAED;IAAC,IAAA,eAAM,EAAC,KAAK,CAAC;IACN,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;6CAElB;AA5BW,eAAe;IAD3B,IAAA,mBAAU,EAAC,OAAO,CAAC;qCAEwB,4BAAY;GAD3C,eAAe,CA6B3B;AA7BY,0CAAe"}

View File

@@ -1,8 +1,9 @@
import { User } from './entities/user.entity';
export declare class UsersService {
private users;
findOne(id: number): User;
findOne(id: string): User;
findAll(): User[];
create(createUserDto: any): void;
update(id: number, updateUserDto: any): void;
create(createUserDto: any): string;
update(id: string, updateUserDto: any): string;
remove(id: string): string;
}

View File

@@ -12,29 +12,43 @@ let UsersService = class UsersService {
constructor() {
this.users = [
{
userId: 1,
userId: '1',
username: 'john',
password: 'changeme',
},
{
userId: 2,
userId: '2',
username: 'maria',
password: 'guess',
},
];
}
findOne(id) {
return this.users.find(user => user.userId === id);
const user = this.users.find(user => user.userId === id);
if (!user)
throw new common_1.NotFoundException(`The requested user not found.`);
return user;
}
findAll() {
if (!this.users.length)
throw new common_1.HttpException(`No user exists.`, common_1.HttpStatus.NOT_FOUND);
return this.users;
}
create(createUserDto) {
this.users.push(createUserDto);
const user = this.users.push(createUserDto);
if (!user)
throw new common_1.HttpException(`The user could not be created.`, common_1.HttpStatus.NOT_FOUND);
return 'User has been created';
}
update(id, updateUserDto) {
const index = this.users.findIndex(user => user.userId === id);
this.users[index] = updateUserDto;
return this.users[index].username + ' has been updated';
}
remove(id) {
const index = this.users.findIndex(user => user.userId === id);
this.users.splice(index, 1);
return 'User has been deleted';
}
};
UsersService = __decorate([

View File

@@ -1 +1 @@
{"version":3,"file":"users.service.js","sourceRoot":"","sources":["../../src/users/users.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAIrC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAAlB;QACE,UAAK,GAAU;YACtB;gBACC,MAAM,EAAE,CAAC;gBACT,QAAQ,EAAE,MAAM;gBAChB,QAAQ,EAAE,UAAU;aACpB;YACD;gBACC,MAAM,EAAE,CAAC;gBACT,QAAQ,EAAE,OAAO;gBACjB,QAAQ,EAAE,OAAO;aACjB;SACD,CAAC;IAmBH,CAAC;IAjBA,OAAO,CAAC,EAAU;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,OAAO;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,aAAkB;QACxB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,EAAU,EAAE,aAAkB;QACpC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,M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