chore: resolved all merge conflicts

This commit is contained in:
Balu Babu
2023-01-24 19:35:40 +05:30
31 changed files with 2864 additions and 14 deletions

View File

@@ -4,13 +4,14 @@ import { pipe } from 'fp-ts/lib/function';
import * as O from 'fp-ts/Option';
import * as TE from 'fp-ts/TaskEither';
import * as T from 'fp-ts/Task';
import * as E from 'fp-ts/Either';
import { User } from './user/user.model';
import * as A from 'fp-ts/Array';
import * as E from 'fp-ts/Either';
import { AuthErrorHandler } from './types/AuthErrorHandler';
import { AuthTokens } from './types/AuthTokens';
import { Response } from 'express';
import { DateTime } from 'luxon';
import { JSON_INVALID } from './errors';
/**
* A workaround to throw an exception in an expression.
@@ -174,3 +175,18 @@ export const authCookieHandler = (
res.status(HttpStatus.OK).redirect(process.env.REDIRECT_URL);
} else res.status(HttpStatus.OK).send();
};
/*
* String to JSON parser
* @param {str} str The string to parse
* @returns {E.Right<T> | E.Left<"json_invalid">} An Either of the parsed JSON
*/
export function stringToJson<T>(
str: string,
): E.Right<T | any> | E.Left<string> {
try {
return E.right(JSON.parse(str));
} catch (err) {
return E.left(JSON_INVALID);
}
}