Yuki Takei 2 lat temu
rodzic
commit
12cf8f48cc

+ 1 - 5
packages/remark-lsx/src/server/routes/list-pages/add-depth-condition.ts

@@ -6,11 +6,7 @@ import type { PageQuery } from './generate-base-query';
 
 
 const { isTopPage } = pagePathUtils;
 const { isTopPage } = pagePathUtils;
 
 
-export const addDepthCondition = (query: PageQuery, pagePath: string, optionsDepth: true | string | null): PageQuery => {
-  // when option strings is 'depth=', the option value is true
-  if (optionsDepth == null || optionsDepth === true) {
-    throw createError(400, 'The value of depth option is invalid.');
-  }
+export const addDepthCondition = (query: PageQuery, pagePath: string, optionsDepth: string): PageQuery => {
 
 
   const range = OptionParser.parseRange(optionsDepth);
   const range = OptionParser.parseRange(optionsDepth);
 
 

+ 0 - 16
packages/remark-lsx/src/server/routes/list-pages/add-num-condition.spec.ts

@@ -9,22 +9,6 @@ describe('addNumCondition()', () => {
 
 
   const queryMock = mock<PageQuery>();
   const queryMock = mock<PageQuery>();
 
 
-  it('throws 400 http-errors instance when the option value is null', () => {
-    // when
-    const caller = () => addNumCondition(queryMock, null);
-
-    // then
-    expect(caller).toThrowError(createError(400, 'The value of num option is invalid.'));
-  });
-
-  it('throws 400 http-errors instance when the option value is true', () => {
-    // when
-    const caller = () => addNumCondition(queryMock, true);
-
-    // then
-    expect(caller).toThrowError(createError(400, 'The value of num option is invalid.'));
-  });
-
   it('set limit with the specified number', () => {
   it('set limit with the specified number', () => {
     // setup
     // setup
     const parseRangeSpy = vi.spyOn(OptionParser, 'parseRange');
     const parseRangeSpy = vi.spyOn(OptionParser, 'parseRange');

+ 1 - 5
packages/remark-lsx/src/server/routes/list-pages/add-num-condition.ts

@@ -7,11 +7,7 @@ import type { PageQuery } from './generate-base-query';
 /**
 /**
  * add num condition that limit fetched pages
  * add num condition that limit fetched pages
  */
  */
-export const addNumCondition = (query: PageQuery, optionsNum: true | string | number | null): PageQuery => {
-  // when option strings is 'num=' or the option value is true
-  if (optionsNum == null || optionsNum === true) {
-    throw createError(400, 'The value of num option is invalid.');
-  }
+export const addNumCondition = (query: PageQuery, optionsNum: string | number): PageQuery => {
 
 
   if (typeof optionsNum === 'number') {
   if (typeof optionsNum === 'number') {
     return query.limit(optionsNum);
     return query.limit(optionsNum);

+ 3 - 3
packages/remark-lsx/src/server/routes/list-pages/index.ts

@@ -102,14 +102,14 @@ export const listPages = async(req: Request & { user: IUser }, res: Response): P
   try {
   try {
     // depth
     // depth
     if (options?.depth != null) {
     if (options?.depth != null) {
-      query = addDepthCondition(query, pagePath, options?.depth);
+      query = addDepthCondition(query, pagePath, options.depth);
     }
     }
     // filter
     // filter
     if (options?.filter != null) {
     if (options?.filter != null) {
-      query = addFilterCondition(query, pagePath, options?.filter);
+      query = addFilterCondition(query, pagePath, options.filter);
     }
     }
     if (options?.except != null) {
     if (options?.except != null) {
-      query = addExceptCondition(query, pagePath, options?.except);
+      query = addExceptCondition(query, pagePath, options.except);
     }
     }
     // num
     // num
     const optionsNum = options?.num || DEFAULT_PAGES_NUM;
     const optionsNum = options?.num || DEFAULT_PAGES_NUM;