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

fix(server): fixed typescript errors #24

Open
wants to merge 1 commit into
base: 1-auth-finished
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions server/search-lessons.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@

import {Request, Response} from 'express';
import {LESSONS} from "./db-data";
import {setTimeout} from "timers";


interface StringParsedQs {
[key: string]: string;
}

export function searchLessons(req: Request, res: Response) {

console.log('Searching for lessons ...');

const queryParams = req.query;
const queryParams = req.query as StringParsedQs;

const courseId = queryParams.courseId,
filter = queryParams.filter || '',
sortOrder = queryParams.sortOrder || 'asc',
pageNumber = parseInt(queryParams.pageNumber) || 0,
pageSize = parseInt(queryParams.pageSize);

let lessons = Object.values(LESSONS).filter(lesson => lesson.courseId == courseId).sort((l1, l2) => l1.id - l2.id);
let lessons = Object.values(LESSONS).filter(lesson => lesson.courseId == +courseId).sort((l1, l2) => l1.id - l2.id);

if (filter) {
lessons = lessons.filter(lesson => lesson.description.trim().toLowerCase().search(filter.toLowerCase()) >= 0);
Expand Down