diff --git a/apple/OmnivoreKit/Sources/Services/InternalModels/InternalLinkedItem.swift b/apple/OmnivoreKit/Sources/Services/InternalModels/InternalLinkedItem.swift index 5f3ba86fe..8927f7b63 100644 --- a/apple/OmnivoreKit/Sources/Services/InternalModels/InternalLinkedItem.swift +++ b/apple/OmnivoreKit/Sources/Services/InternalModels/InternalLinkedItem.swift @@ -68,7 +68,6 @@ extension Sequence where Element == InternalLinkedItem { context.performAndWait { linkedItems = map { $0.asManagedObject(inContext: context) } - print("LINKED ITEMS", linkedItems) do { try context.save() print("LinkedItems saved succesfully") diff --git a/packages/api/src/routers/page_router.ts b/packages/api/src/routers/page_router.ts index d1522a3dc..39ae6295a 100644 --- a/packages/api/src/routers/page_router.ts +++ b/packages/api/src/routers/page_router.ts @@ -3,7 +3,12 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import express from 'express' -import { ArticleSavingRequestStatus, CreateArticleErrorCode, PageType, UploadFileStatus } from '../generated/graphql' +import { + ArticleSavingRequestStatus, + CreateArticleErrorCode, + PageType, + UploadFileStatus, +} from '../generated/graphql' import { isSiteBlockedForParse } from '../utils/blocked' import cors from 'cors' import { env } from '../env' @@ -13,8 +18,17 @@ import { corsConfig } from '../utils/corsConfig' import { createPageSaveRequest } from '../services/create_page_save_request' import { initModels } from '../server' import { kx } from '../datalayer/knex_config' -import { fileNameForFilePath, generateSlug, isString, titleForFilePath, validateUuid } from '../utils/helpers' -import { generateUploadFilePathName, generateUploadSignedUrl } from '../utils/uploads' +import { + fileNameForFilePath, + generateSlug, + isString, + titleForFilePath, + validateUuid, +} from '../utils/helpers' +import { + generateUploadFilePathName, + generateUploadSignedUrl, +} from '../utils/uploads' import { Claims } from '../resolvers/types' import { createPage, getPageByParam, updatePage } from '../elastic/pages' import { createPubSubClient } from '../datalayer/pubsub' @@ -36,10 +50,26 @@ export function pageRouter() { // Get the content type from the query params const { url, clientRequestId } = req.query const contentType = req.headers['content-type'] - console.log('contentType', contentType, 'url', url, 'clientRequestId', clientRequestId) + console.log( + 'contentType', + contentType, + 'url', + url, + 'clientRequestId', + clientRequestId + ) - if (!isString(url) || !isString(contentType) || !isString(clientRequestId)) { - console.log('creating page from pdf failed', url, contentType, clientRequestId) + if ( + !isString(url) || + !isString(contentType) || + !isString(clientRequestId) + ) { + console.log( + 'creating page from pdf failed', + url, + contentType, + clientRequestId + ) return res.status(400).send({ errorCode: 'BAD_DATA' }) } @@ -61,16 +91,18 @@ export function pageRouter() { userId: claims.uid, fileName: fileName, status: UploadFileStatus.Initialized, - contentType: "application/pdf", + contentType: 'application/pdf', }) const uploadFilePathName = generateUploadFilePathName( uploadFileData.id, - fileName, + fileName ) - const signedUrl = await generateUploadSignedUrl(uploadFilePathName, "application/pdf") - + const signedUrl = await generateUploadSignedUrl( + uploadFilePathName, + 'application/pdf' + ) const page = await getPageByParam({ userId: claims.uid, @@ -89,22 +121,25 @@ export function pageRouter() { ) } else { console.log('creating page') - const pageId = await createPage({ - url: signedUrl, - id: clientRequestId, - userId: claims.uid, - title: title, - hash: uploadFilePathName, - content: '', - pageType: PageType.File, - uploadFileId: uploadFileData.id, - slug: generateSlug(uploadFilePathName), - createdAt: new Date(), - savedAt: new Date(), - readingProgressPercent: 0, - readingProgressAnchorIndex: 0, - state: ArticleSavingRequestStatus.Processing, - }, ctx) + const pageId = await createPage( + { + url: signedUrl, + id: clientRequestId, + userId: claims.uid, + title: title, + hash: uploadFilePathName, + content: '', + pageType: PageType.File, + uploadFileId: uploadFileData.id, + slug: generateSlug(uploadFilePathName), + createdAt: new Date(), + savedAt: new Date(), + readingProgressPercent: 0, + readingProgressAnchorIndex: 0, + state: ArticleSavingRequestStatus.Processing, + }, + ctx + ) if (!pageId) { return res.sendStatus(500) } diff --git a/packages/api/src/utils/helpers.ts b/packages/api/src/utils/helpers.ts index baea054b2..c4db77d44 100644 --- a/packages/api/src/utils/helpers.ts +++ b/packages/api/src/utils/helpers.ts @@ -256,10 +256,11 @@ export const titleForFilePath = (url: string): string => { } export const validateUuid = (str: string): boolean => { - const regexExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi; + const regexExp = + /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi return regexExp.test(str) } export const isString = (check: any): check is string => { - return (typeof check === 'string' || check instanceof String) -} \ No newline at end of file + return typeof check === 'string' || check instanceof String +} diff --git a/packages/api/src/utils/uploads.ts b/packages/api/src/utils/uploads.ts index 630349938..f69189f56 100644 --- a/packages/api/src/utils/uploads.ts +++ b/packages/api/src/utils/uploads.ts @@ -24,7 +24,12 @@ export const generateUploadSignedUrl = async ( // return 'http://localhost:3000/uploads/' + filePathName // } - console.log("signed URL", filePathName, contentType, selectedBucket || bucketName) + console.log( + 'signed URL', + filePathName, + contentType, + selectedBucket || bucketName + ) // These options will allow temporary uploading of file with requested content type const options: GetSignedUrlConfig = {