- Users should be able to login with a password.
- There should be only **one** user entity but your entity should support two roles 'Host' and 'Listener'.
- Create Guards to protect private resolvers.
- Use JWT as authentication method.
- Create a decorator to get the logged in user.
- createAccount
- login
- editProfile
- seeProfile
- podcasts.service.spec.ts
- jwt.service.spec.ts
- users.service.spec.ts
- E2E test the users.resolver.ts and podcasts.resolver.ts
- New update!: To test Listener role,
likePodcast
resolver is created likePodcast
can be calledonly
by user withListener role
likePodcast
will like the podcast if never been liked, otherwise dislike
podcast.resolver.ts
- Created podcastRating entity with rating column as N:M mapper
- After updating podcastRating, get average and update rating of the podcast
user.resolver.ts
- heroku doesn't support sqlite => if production, use postgres
- if production, default value of playground is false => manually set true
// app.module.ts
playground: true,
introspection: true,
npm i bcrypt @types/bcrypt --dev-only
npm i --save @nestjs/config
npm i cross-env
touch .env.dev .env.prod .env.test
echo .env.dev >> .gitignore
npm i joi
nest g mo auth
const episodes = await this.episodes.find({
podcast: { id: podcastId },
});
- QueryBuilder sample
const subscribedUser = await this.users
.createQueryBuilder('user')
.innerJoin(
'user_subscribed_podcasts_podcast',
'subscribedPodcast',
'user.id = :userId',
{ userId },
)
.andWhere('subscribedPodcast.podcastId = :podcastId', { podcastId })
.getOne();
-
To Handle drop constraint error, set
onDelete: 'cascade'
atManyToOne