Skip to content
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ POSTGRES_PORT=5432
JWT_SECRET=supersecretkey
JWT_ALGORITHM=HS256
APP_PORT=3000

9 changes: 8 additions & 1 deletion src/articles/articles.schema.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { MAX_PAGINATION_LIMIT } from '@/constants';
import type { Profile } from '@profiles/profiles.schema';
import { type Static, Type } from '@sinclair/typebox';
import { createInsertSchema, createSelectSchema } from 'drizzle-typebox';
Expand Down Expand Up @@ -73,7 +74,13 @@ export type ArticleInDb = Omit<
export type ArticleFavoritedBy = typeof favoriteArticles.$inferSelect;

export const ArticleFeedQuerySchema = Type.Object({
limit: Type.Optional(Type.Number({ minimum: 1, default: 20 })),
limit: Type.Optional(
Type.Number({
minimum: 1,
maximum: MAX_PAGINATION_LIMIT,
default: 20,
}),
),
offset: Type.Optional(Type.Number({ minimum: 0, default: 0 })),
});
export const ListArticlesQuerySchema = Type.Composite([
Expand Down
6 changes: 6 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Maximum number of items that can be returned in a single request.
*
* Set to 1000 since since the article body is not returned and the returned articles are small
*/
export const MAX_PAGINATION_LIMIT = 1000;
Loading