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

Add endpoint to post announcements #180

Merged
merged 6 commits into from
Jun 5, 2024

Conversation

kishan1735
Copy link
Contributor

No description provided.

Copy link
Member

@soumitradev soumitradev left a comment

Choose a reason for hiding this comment

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

Small changes, LGTM otherwise

@@ -28,4 +28,5 @@ export const serverSchema = z.object({
SESSION_MAX_AGE_MS: z.coerce.number().default(86400000),
VITE_FRONTEND_URL: z.string().url().min(1),
VITE_CMS_EXTENSION_ID: z.string().min(1),
CHRONO_SECRET: z.optional(z.string().min(1)),
Copy link
Member

Choose a reason for hiding this comment

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

Don't make this optional

@PrimaryGeneratedColumn("uuid")
id!: string;

@Column({ type: "varchar", length: 800 })
Copy link
Member

Choose a reason for hiding this comment

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

Add a title field as well

Comment on lines 18 to 40
export const createAnnoucement = async (req: Request, res: Response) => {
try {
const { chronoSecret, message } = req.body;

if (env.CHRONO_SECRET !== chronoSecret) {
return res.status(401).json({ message: "Chrono Secret is incorrect" });
}

await announcementRepository
.createQueryBuilder()
.insert()
.into(Announcement)
.values({
message,
})
.execute();

return res
.status(201)
.json({ message: "Announcement Created Successfully" });
} catch (err) {
return res.status(500).json({ message: "Internal Server Error" });
}
Copy link
Member

Choose a reason for hiding this comment

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

Add title here as well, also move the chronoSecret from the body to the headers of the request instead, since it's used for authentication in this case.

Copy link
Member

@soumitradev soumitradev left a comment

Choose a reason for hiding this comment

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

LGTM

@soumitradev soumitradev added this pull request to the merge queue Jun 5, 2024
Merged via the queue into master with commit 1a35c3b Jun 5, 2024
1 check passed
@soumitradev soumitradev linked an issue Jun 5, 2024 that may be closed by this pull request
@skoriop skoriop deleted the add-endpoint-to-post-announcements branch July 18, 2024 06:12
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.

Add endpoint to post announcements
2 participants