wynn/ts/src/services/temporal/index.ts
a 53f46934e8
Some checks failed
commit-tag / commit-tag-image (map[context:./migrations file:./migrations/Dockerfile name:migrations]) (push) Successful in 21s
commit-tag / commit-tag-image (map[context:./ts file:./ts/Dockerfile name:ts]) (push) Has been cancelled
noot
2025-06-14 18:04:46 -05:00

26 lines
633 B
TypeScript

import { Client, Connection } from '@temporalio/client'
import { config } from '#/config'
import { c } from '#/di'
c.bind({
provide: Client,
async: true,
useFactory: async () => {
const connection = await Connection.connect({
address: config.TEMPORAL_HOSTPORT,
})
const client = new Client({
connection,
namespace: config.TEMPORAL_NAMESPACE,
dataConverter: {
payloadConverterPath: require.resolve('../../payload_converter'),
},
})
process.on('exit', () => {
console.log('closing temporal client')
client.connection.close()
})
return client
},
})