Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

latest-changes-of-ehsaan-stream #2

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

latest-changes-of-ehsaan-stream #2

wants to merge 9 commits into from

Conversation

Nehal409
Copy link

@Nehal409 Nehal409 commented Jul 5, 2023

This PR contains all the latest changes of ehsaan stream- BE. Including migration and seeding

stream-api/db/data-source.ts Outdated Show resolved Hide resolved
stream-api/db/migrations/1675765917554-createTables.ts Outdated Show resolved Hide resolved
stream-api/db/migrations/1675765917554-createTables.ts Outdated Show resolved Hide resolved
stream-api/db/migrations/1675766031182-tracksSeeds.ts Outdated Show resolved Hide resolved
stream-api/package.json Show resolved Hide resolved
stream-api/src/dto/update-channel.dto.ts Outdated Show resolved Hide resolved
Comment on lines 25 to 30
@OneToMany(() => Track, (tracks) => tracks.channel)
tracks: Track;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to have tracks with channel?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we will need it. Every channel will have its separate tracks and we will call them accordingly from the api

Comment on lines 56 to 105
'Channel not found. Cannot create Tracks',
HttpStatus.BAD_REQUEST,
);
const newTrack = this.trackRepository.create({
...createTracks,
channel,
});
return this.trackRepository.save(newTrack);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why create new channel? we just need to insert new track with channelId if channel exists

Comment on lines +27 to +37
async login({ name, password }: CreateUserDto) {
const user = await this.userRepository.findOne({where: {name}});
if (!user) {
throw new HttpException("User not found", HttpStatus.UNAUTHORIZED);
}

const areEqual = await comparePassword(password, user.password);

if (!areEqual) {
throw new HttpException("Invalid credentials", HttpStatus.UNAUTHORIZED);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix formatting

Comment on lines +13 to +23
async createUser(createUserDto: CreateUserDto) {
try {
const password = encodePassword(createUserDto.password);
const newUser = this.userRepository.create({ ...createUserDto, password });
await this.userRepository.save(newUser);
return newUser;

} catch (error) {
throw new InternalServerErrorException();

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be protected, cant have users be created.

export class CreateChannelDto {
englishName: string;
arabicName: string;
channelRoute: string;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats this route?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every channel will have there unique route.
For Example, Moulana Tariq Jameel route will be @MTJ.
https://ehsaan-stream.web.app/channels/@MTJ
We will call channels with this route. It is a unique column.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok this is the identifier or handle
not route. change to a different name

englishName: string;
arabicName: string;
channelRoute: string;
thumbnail: string;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this thumbnail path?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of storing the full path of the thumbnail in the database, we store only the thumbnail name. We have implemented a new route that retrieves the saved thumbnail file from the file system (fs) and serves it to the user based on the thumbnail name stored in the database.
Here how it works,
const filePath = join(process.cwd(), 'uploads/thumbnails', channel.thumbnail);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets rename to key then

@@ -0,0 +1,4 @@
export class CreateTrackDto {
name: string;
src: string;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is mp3 track path?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have done same thing for mp3 tracks files what we did for thumbnail files

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the src column the name of the mp3 file is stored

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets rename to key then

name: 'channelId',
referencedColumnName: 'id',
})
public channel: Channel;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants