Created
August 22, 2022 18:30
-
-
Save glommer/d84b67aa1cbb2d7cbe1aa023d1510cc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ChiselEvent } from "@chiselstrike/api"; | |
import { TopOfBook } from "../models/TopOfBook"; | |
function toJSON(buffer: ArrayBuffer) { | |
return JSON.parse(String.fromCharCode.apply(null, new Uint8Array(buffer))); | |
} | |
export default async function (event: ChiselEvent) { | |
const bookUpdate = toJSON(event.value); | |
const symbol = bookUpdate.symbol; | |
await TopOfBook.upsert({ | |
restrictions: { symbol }, | |
create: bookUpdate, | |
update: bookUpdate, | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment