- Extract database schema and migrations into @openreader/database - Extract startup and orchestration scripts into @openreader/bootstrap - Move compute-worker into packages/compute-worker - Remove runtime dependency on drizzle-kit - Update Dockerfile to deploy isolated packages without merging node_modules
17 lines
428 B
TypeScript
17 lines
428 B
TypeScript
export type JsonCodec<T> = {
|
|
encode(value: T): Uint8Array;
|
|
decode(data: Uint8Array): T;
|
|
};
|
|
|
|
export function createJsonCodec<T>(): JsonCodec<T> {
|
|
const encoder = new TextEncoder();
|
|
const decoder = new TextDecoder();
|
|
return {
|
|
encode(value: T): Uint8Array {
|
|
return encoder.encode(JSON.stringify(value));
|
|
},
|
|
decode(data: Uint8Array): T {
|
|
return JSON.parse(decoder.decode(data)) as T;
|
|
},
|
|
};
|
|
}
|