Skip to content

Commit

Permalink
fixing ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasambry committed Nov 12, 2024
1 parent d691fb4 commit 8822596
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions server/controllers/analytic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ analyticController.router.post(
// Retrieve current user session or save the new one.
// eslint-disable-next-line prefer-const
let [sessionCount, userPhase] = await Promise.all([
AppDataSource.getRepository(AnalyticSession).count({ where: { id: data.sessionId } }),
AppDataSource.getRepository(User).createQueryBuilder('user').select('user.firstlogin').where({ id: data.userId }).getRawOne(),
AppDataSource.getRepository(AnalyticSession).count({where: {id: data.sessionId}}),

Check failure on line 281 in server/controllers/analytic.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `where:·{id:·data.sessionId}` with `·where:·{·id:·data.sessionId·}·`
AppDataSource.getRepository(User).createQueryBuilder('user').select('user.firstlogin').where({id: data.userId}).getRawOne(),

Check failure on line 282 in server/controllers/analytic.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `id:·data.userId` with `·id:·data.userId·`
]);

if (sessionCount === 0 && data.event === 'pageview' && data.params?.isInitial) {
Expand Down Expand Up @@ -331,7 +331,7 @@ analyticController.router.post(
pagePerf.data = data.params.perf as BrowserPerf;
AppDataSource.getRepository(AnalyticPerformance).save(pagePerf).catch(); // no need to wait
} else if (data.event === 'session' && data.params?.duration) {
AppDataSource.getRepository(AnalyticSession).update({ id: data.sessionId }, { duration: data.params?.duration }).catch(); // no need to wait
AppDataSource.getRepository(AnalyticSession).update({id: data.sessionId}, {duration: data.params?.duration}).catch(); // no need to wait

Check failure on line 334 in server/controllers/analytic.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `id:·data.sessionId},·{duration:·data.params?.duration` with `·id:·data.sessionId·},·{·duration:·data.params?.duration·`
}
} catch (e) {
logger.error(e);
Expand Down
8 changes: 4 additions & 4 deletions server/h5p/get-h5p-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ export const getH5pRouter = async () => {
res.status(400).send('Malformed request');
return;
}
const { id: contentId, metadata } = await h5pEditor.saveOrUpdateContentReturnMetaData(
const {id: contentId, metadata} = await h5pEditor.saveOrUpdateContentReturnMetaData(

Check failure on line 223 in server/h5p/get-h5p-router.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `id:·contentId,·metadata` with `·id:·contentId,·metadata·`
undefined as unknown as string,
req.body.params.params,
req.body.params.metadata,
req.body.library,
req.user as unknown as H5pUser,
);
res.status(200).json({ contentId, metadata });
res.status(200).json({contentId, metadata});

Check failure on line 230 in server/h5p/get-h5p-router.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `contentId,·metadata` with `·contentId,·metadata·`
}),
);

Expand All @@ -238,14 +238,14 @@ export const getH5pRouter = async () => {
res.status(400).send('Malformed request');
return;
}
const { id: contentId, metadata } = await h5pEditor.saveOrUpdateContentReturnMetaData(
const {id: contentId, metadata} = await h5pEditor.saveOrUpdateContentReturnMetaData(

Check failure on line 241 in server/h5p/get-h5p-router.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `id:·contentId,·metadata` with `·id:·contentId,·metadata·`
req.params.contentId,
req.body.params.params,
req.body.params.metadata,
req.body.library,
req.user as unknown as H5pUser,
);
res.status(200).sendJSON({ contentId, metadata });
res.status(200).sendJSON({contentId, metadata});

Check failure on line 248 in server/h5p/get-h5p-router.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `contentId,·metadata` with `·contentId,·metadata·`
}),
);

Expand Down
2 changes: 1 addition & 1 deletion server/middlewares/authenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AppDataSource } from '../utils/data-source';

const secret: string = process.env.APP_SECRET || '';

export function authenticate(userType: UserType | undefined = undefined): RequestHandler {
export function authenticate(userType?: UserType | UserType[] | undefined) {
return async (req: Request, res: Response, next: NextFunction): Promise<void> => {
let token: string;
if (req.cookies && req.cookies['access-token']) {
Expand Down
2 changes: 1 addition & 1 deletion server/middlewares/handleErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface PromiseRequestHandler extends RequestHandler {
(req: Request, res: Response, next: NextFunction): Promise<void> | void;
}

export function handleErrors(fn: RequestHandler): RequestHandler {
export function handleErrors(fn: PromiseRequestHandler): PromiseRequestHandler {
return (req: Request, res: Response, next: NextFunction): void => {
const sendError = (err: Error | AppError): void => {
logger.error(err.message);
Expand Down

0 comments on commit 8822596

Please sign in to comment.