@mrsimonemms/temporal-codec-server
v0.4.3
Published
Encode and decode your Temporal data
Maintainers
Readme
temporal-codec-server
Encode and decode your Temporal data with TypeScript
Temporal SDK example
See keys.example.yaml for an example key file.
For best results, use an environment variable rather than hardcoding the file path.
Installation
npm install --save @mrsimonemms/temporal-codec-serverClient
import { Connection, Client } from '@temporalio/client';
import { AESCodec } from '@mrsimonemms/temporal-codec-server';
async function run() {
const connection = await Connection.connect();
const client = new Client({
connection,
dataConverter: {
// Load the payload converter
payloadCodecs: [await AESCodec.create('/path/to/keyfile')],
},
// For additional options, see https://docs.temporal.io/develop/typescript/temporal-clients#connect-to-development-service
});
// Continue...
}
run().catch((err) => {
console.error(err);
process.exit(1);
});Worker
import { NativeConnection, Worker } from '@temporalio/worker';
import { AESCodec } from '@mrsimonemms/temporal-codec-server';
async function run() {
const connection = await NativeConnection.connect();
try {
const worker = await Worker.create({
dataConverter: {
// Load the payload converter
payloadCodecs: [await AESCodec.create('/path/to/keyfile')],
},
connection,
// For additional options, see https://docs.temporal.io/develop/typescript/temporal-clients#set-task-queue
});
// Continue...
} catch {
await connection.close();
}
}
run().catch((err) => {
console.error(err);
process.exit(1);
});