UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

1 lines 1.44 kB
{"version":3,"file":"update-last-used.mjs","names":[],"sources":["../../../src/services/client-integrations/update-last-used.ts"],"sourcesContent":["import { ClientIntegrationsRepository } from \"../../libs/repositories/index.js\";\nimport type { ServiceFn } from \"../../utils/services/types.js\";\n\nconst updateLastUsed: ServiceFn<\n\t[\n\t\t{\n\t\t\tid: number;\n\t\t\tipAddress: string | null;\n\t\t\tuserAgent: string | null;\n\t\t},\n\t],\n\tundefined\n> = async (context, data) => {\n\tconst ClientIntegrations = new ClientIntegrationsRepository(\n\t\tcontext.db.client,\n\t\tcontext.config.db,\n\t);\n\n\tconst updateRes = await ClientIntegrations.updateMultiple({\n\t\tdata: {\n\t\t\tlast_used_at: new Date().toISOString(),\n\t\t\tlast_used_ip: data.ipAddress,\n\t\t\tlast_used_user_agent: data.userAgent,\n\t\t},\n\t\twhere: [\n\t\t\t{\n\t\t\t\tkey: \"id\",\n\t\t\t\toperator: \"=\",\n\t\t\t\tvalue: data.id,\n\t\t\t},\n\t\t],\n\t});\n\tif (updateRes.error) return updateRes;\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: undefined,\n\t};\n};\n\nexport default updateLastUsed;\n"],"mappings":"+DAGA,MAAM,EASF,MAAO,EAAS,IAAS,CAM5B,IAAM,EAAY,MAAM,IALO,EAC9B,EAAQ,GAAG,OACX,EAAQ,OAAO,EAGyB,CAAC,CAAC,eAAe,CACzD,KAAM,CACL,aAAc,IAAI,KAAK,CAAA,CAAE,YAAY,EACrC,aAAc,EAAK,UACnB,qBAAsB,EAAK,SAC5B,EACA,MAAO,CACN,CACC,IAAK,KACL,SAAU,IACV,MAAO,EAAK,EACb,CACD,CACD,CAAC,EAGD,OAFI,EAAU,MAAc,EAErB,CACN,MAAO,IAAA,GACP,KAAM,IAAA,EACP,CACD"}