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

release #114

Merged
merged 7 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
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
132 changes: 127 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@emotion/cache": "^11.11.0",
"@mui/material-nextjs": "^5.15.11",
"arg": "^5.0.2",
"pino": "^8.19.0",
"react-markdown": "^9.0.1",
"reactjrx": "^1.79.1",
"remark-gfm": "^4.0.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/api/serverless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ const serverlessConfiguration: AWS & any = {
shouldStartNameWithService: true,
binaryMediaTypes: [`*/*`]
},
logs: {
restApi: true
},
// Do this if you want to load env vars into the Serverless environment AND
// automatically configure all your functions with them.
// This is usually not recommended to avoid loading secrets by accident (e.g. AWS_SECRET_ACCESS_KEY)
Expand Down
8 changes: 0 additions & 8 deletions packages/api/src/functions/refreshMetadata/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ import { handlerPath } from "@libs/handler-resolver"
export default {
handler: `${handlerPath(__dirname)}/handler.main`,
role: "lambdaDefault",
/**
* Because this lambda check and lock the process
* we need to avoid concurrent access. This way we ensure
* the lock is always checked in sync.
*
* This lambda should stay simple and fast (check/lock)
*/
reservedConcurrency: 1,
events: [
{
http: {
Expand Down
8 changes: 0 additions & 8 deletions packages/api/src/functions/refreshMetadataCollection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ import { handlerPath } from "@libs/handler-resolver"
export default {
handler: `${handlerPath(__dirname)}/handler.main`,
role: "lambdaDefault",
/**
* Because this lambda check and lock the process
* we need to avoid concurrent access. This way we ensure
* the lock is always checked in sync.
*
* This lambda should stay simple and fast (check/lock)
*/
reservedConcurrency: 1,
events: [
{
http: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const lambda: ValidatedEventAPIGatewayProxyEvent<typeof schema> = async (

await deleteLock(supabase, lockId)

Logger.log(`lambda executed with success for ${collection._id}`)
Logger.info(`lambda executed with success for ${collection._id}`)

return {
statusCode: 200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,5 @@ import { handlerPath } from "@libs/handler-resolver"
export default {
handler: `${handlerPath(__dirname)}/handler.main`,
role: "lambdaDefault",
/**
* This lambda can be heavy on local development.
* To avoid memory issues and CPU overuse we lock
* it at 1 concurrency
*/
...(process.env.OFFLINE === "true" && {
reservedConcurrency: 1
}),
timeout: 60 * 15 // 15mn
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const lambda: ValidatedEventAPIGatewayProxyEvent<typeof schema> = async (
deleteLock(supabase, lockId)
])

Logger.log(`lambda executed with success for ${book._id}`)
Logger.info(`lambda executed with success for ${book._id}`)

return {
statusCode: 200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,5 @@ import { handlerPath } from "@libs/handler-resolver"
export default {
handler: `${handlerPath(__dirname)}/handler.main`,
role: "lambdaDefault",
/**
* This lambda can be heavy on local development.
* To avoid memory issues and CPU overuse we lock
* it at 1 concurrency
*/
...(process.env.OFFLINE === "true" && {
reservedConcurrency: 1
}),
timeout: 60 * 15 // 15mn
}
8 changes: 0 additions & 8 deletions packages/api/src/functions/syncDataSource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ import { handlerPath } from "@libs/handler-resolver"
export default {
handler: `${handlerPath(__dirname)}/handler.main`,
role: "lambdaDefault",
/**
* Because this lambda check and lock the process
* we need to avoid concurrent access. This way we ensure
* the lock is always checked in sync.
*
* This lambda should stay simple and fast (check/lock)
*/
reservedConcurrency: 1,
events: [
{
http: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ const lambda: ValidatedEventAPIGatewayProxyEvent<typeof schema> = async (
authorization
})

deleteLock(supabase, lockId)
await deleteLock(supabase, lockId)
} catch (e) {
deleteLock(supabase, lockId)
await deleteLock(supabase, lockId)

throw e
}
Expand Down
12 changes: 6 additions & 6 deletions packages/api/src/libs/books/retrieveMetadataAndSaveCover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { isBookProtected } from "@libs/couch/isBookProtected"
import nano from "nano"
import { atomicUpdate } from "@libs/couch/dbHelpers"

const logger = Logger.namespace("retrieveMetadataAndSaveCover")
const logger = Logger.child({module: "retrieveMetadataAndSaveCover"})

export type RetrieveMetadataAndSaveCoverContext = {
userName: string
Expand All @@ -39,7 +39,7 @@ export const retrieveMetadataAndSaveCover = async (
db: nano.DocumentScope<unknown>
}
) => {
logger.log(
logger.info(
`syncMetadata run for user ${ctx.userName} with book ${ctx.book._id}`
)
let bookNameForDebug = ""
Expand All @@ -49,7 +49,7 @@ export const retrieveMetadataAndSaveCover = async (
try {
bookNameForDebug = reduceMetadata(ctx.book.metadata).title || ""

logger.log(
logger.info(
`syncMetadata processing ${ctx.book._id} with resource id ${ctx.link.resourceId}`
)

Expand Down Expand Up @@ -189,8 +189,8 @@ export const retrieveMetadataAndSaveCover = async (
)
.sort()[0]

Logger.log(`coverRelativePath`, coverRelativePath)
Logger.log(`opfBasePath`, opfBasePath)
logger.info(`coverRelativePath`, coverRelativePath)
logger.info(`opfBasePath`, opfBasePath)

metadataList.push({
type: "file",
Expand All @@ -210,7 +210,7 @@ export const retrieveMetadataAndSaveCover = async (
console.log(`No cover path found for ${tmpFilePath}`)
}
} else {
logger.log(
logger.info(
`${contentType} cannot be extracted to retrieve information (cover, etc)`
)
}
Expand Down
Loading