Skip to content

Commit

Permalink
fix: missing optional check in serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
gempain committed Mar 19, 2021
1 parent 7c261f1 commit ca36dcb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/hooks/handlers/web/get-payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Branch } from '../../../entities/sites/branch';
import { Release } from '../../../entities/releases/release';
import { getBranchUrl } from '../../../entities/sites/get-branch-url';
import { getSiteUrl } from '../../../entities/sites/get-site-url';
import { serializeForm } from '../../../entities/forms/serialize-form';

function serializeUser(user: User) {
return {
Expand Down Expand Up @@ -96,7 +97,7 @@ function serializeBranch(site: Site, branch: Branch) {
slug: branch.slug,
release: branch.release,
hasPassword: !!branch.password,
redirects: branch.redirects.map(redirect => ({
redirects: branch.redirects?.map(redirect => ({
_id: redirect._id,
type: redirect.type,
path: redirect.path,
Expand Down Expand Up @@ -140,6 +141,7 @@ function serializeRelease(release: Release) {
name: release.name,
date: release.date,
branches: release.branches,
forms: release.forms?.map(serializeForm),
};
}

Expand Down
4 changes: 3 additions & 1 deletion src/socket/message-builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getBranchUrl } from '../entities/sites/get-branch-url';
import { Branch } from '../entities/sites/branch';
import { Team } from '../entities/teams/team';
import { Release } from '../entities/releases/release';
import { serializeForm } from '../entities/forms/serialize-form';

function serializeTeam(team: Team) {
return {
Expand All @@ -25,7 +26,7 @@ function serializeBranch(site: Site, branch: Branch) {
slug: branch.slug,
release: branch.release,
hasPassword: !!branch.password,
redirects: branch.redirects.map(redirect => ({
redirects: branch.redirects?.map(redirect => ({
_id: redirect._id,
type: redirect.type,
path: redirect.path,
Expand Down Expand Up @@ -61,6 +62,7 @@ function serializeRelease(release: Release) {
name: release.name,
date: release.date,
branches: release.branches,
forms: release.forms?.map(serializeForm),
};
}

Expand Down

0 comments on commit ca36dcb

Please sign in to comment.