mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
Add UsersModule
This contains the module, a service (which only returns mock data), a model and the UserInfo DTO. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
774f9cd8a3
commit
27126bcde1
5 changed files with 64 additions and 0 deletions
12
src/users/user-info.dto.ts
Normal file
12
src/users/user-info.dto.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { IsString } from 'class-validator';
|
||||
|
||||
export class UserInfoDto {
|
||||
@IsString()
|
||||
userName: string;
|
||||
@IsString()
|
||||
displayName: string;
|
||||
@IsString()
|
||||
photo: string;
|
||||
@IsString()
|
||||
email: string;
|
||||
}
|
8
src/users/user.entity.ts
Normal file
8
src/users/user.entity.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { Entity, PrimaryGeneratedColumn } from 'typeorm';
|
||||
|
||||
@Entity()
|
||||
export class User {
|
||||
//TODO: Still missing many properties
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
}
|
11
src/users/users.module.ts
Normal file
11
src/users/users.module.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { User } from './user.entity';
|
||||
import { UsersService } from './users.service';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([User])],
|
||||
providers: [UsersService],
|
||||
exports: [UsersService],
|
||||
})
|
||||
export class UsersModule {}
|
18
src/users/users.service.spec.ts
Normal file
18
src/users/users.service.spec.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { UsersService } from './users.service';
|
||||
|
||||
describe('UsersService', () => {
|
||||
let service: UsersService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [UsersService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<UsersService>(UsersService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
15
src/users/users.service.ts
Normal file
15
src/users/users.service.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { UserInfoDto } from './user-info.dto';
|
||||
|
||||
@Injectable()
|
||||
export class UsersService {
|
||||
getUserInfo(): UserInfoDto {
|
||||
//TODO: Use the database
|
||||
return {
|
||||
displayName: 'foo',
|
||||
userName: 'fooUser',
|
||||
email: 'foo@example.com',
|
||||
photo: '',
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue