Skip to content

Commit

Permalink
Merge pull request #71 from mbret/develop
Browse files Browse the repository at this point in the history
release
  • Loading branch information
mbret authored Feb 26, 2024
2 parents 7c25c07 + 7639040 commit c7be288
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 13 deletions.
7 changes: 6 additions & 1 deletion packages/api/src/functions/refreshMetadata/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import { getAwsLambda, withMiddy } from "@libs/lambda"
import { getNormalizedHeader } from "@libs/utils"
import { STAGE } from "../../constants"
import schema from "./schema"
import { InvokeCommand } from "@aws-sdk/client-lambda"

const lambda: ValidatedEventAPIGatewayProxyEvent<typeof schema> = async (
event
) => {
await getAwsLambda().invoke({
const client = getAwsLambda()

const command = new InvokeCommand({
InvocationType: "Event",
FunctionName: `oboku-api-${STAGE}-refreshMetadataLongProcess`,
Payload: JSON.stringify({
Expand All @@ -19,6 +22,8 @@ const lambda: ValidatedEventAPIGatewayProxyEvent<typeof schema> = async (
})
})

await client.send(command)

return {
statusCode: 202,
body: JSON.stringify({})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,6 @@ const lambda: ValidatedEventAPIGatewayProxyEvent<typeof schema> = async (
}

export const main = withMiddy(lambda, {
withCors: false
withCors: false,
withJsonBodyParser: false
})
6 changes: 5 additions & 1 deletion packages/api/src/functions/syncDataSource/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { getAwsLambda, withMiddy } from "@libs/lambda"
import { getNormalizedHeader } from "@libs/utils"
import { STAGE } from "../../constants"
import schema from "./schema"
import { InvokeCommand } from "@aws-sdk/client-lambda"

const lambda: ValidatedEventAPIGatewayProxyEvent<typeof schema> = async (
event
) => {
await getAwsLambda().invoke({
const lambda = getAwsLambda()
const command = new InvokeCommand({
InvocationType: "Event",
FunctionName: `oboku-api-${STAGE}-syncDataSourceLongProcess`,
Payload: JSON.stringify({
Expand All @@ -19,6 +21,8 @@ const lambda: ValidatedEventAPIGatewayProxyEvent<typeof schema> = async (
})
})

await lambda.send(command)

return {
statusCode: 202,
body: JSON.stringify({})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,6 @@ const lambda: ValidatedEventAPIGatewayProxyEvent<typeof schema> = async (
}

export const main = withMiddy(lambda, {
withCors: false
withCors: false,
withJsonBodyParser: false
})
4 changes: 2 additions & 2 deletions packages/api/src/libs/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import cors from "@middy/http-cors"
import { OFFLINE } from "../constants"
import { transpileSchema } from "@middy/validator/transpile"
import validator from "@middy/validator"
import { Lambda } from "@aws-sdk/client-lambda"
import { LambdaClient } from "@aws-sdk/client-lambda"

export const withMiddy = (
handler: any,
Expand Down Expand Up @@ -103,7 +103,7 @@ export const withMiddy = (
}

export const getAwsLambda = () =>
new Lambda({
new LambdaClient({
region: "us-east-1",
...(OFFLINE && {
endpoint: `http://localhost:3002`
Expand Down
7 changes: 1 addition & 6 deletions packages/web/src/collections/databaseHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { CollectionDocType, directives } from "@oboku/shared"
import { useLocalSettings } from "../settings/states"
import { useForeverQuery } from "reactjrx"
import { latestDatabase$ } from "../rxdb/useCreateDatabase"
import { map, switchMap } from "rxjs"
import { CollectionDocType } from "@oboku/shared"
import { keyBy } from "lodash"
import { Database } from "../rxdb"
import { useVisibleBookIds } from "../books/states"

export type Collection = CollectionDocType

Expand Down
8 changes: 7 additions & 1 deletion packages/web/src/queries/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ export const queryClient = new QueryClient({
* rxdb change with middleware. However since it's harder to maintain we just don't
* use cache by default.
*/
gcTime: 0
gcTime: 0,
/**
* @important
* offline PWA.
* Don't forget to set it back to default when making online queries
*/
networkMode: "always"
}
}
})

0 comments on commit c7be288

Please sign in to comment.