This repository was archived by the owner on Sep 17, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +64
-0
lines changed Expand file tree Collapse file tree 4 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 99 " ABCxFF"
1010 ],
1111 "scripts" : {
12+ "push_event" : {
13+ "public" : true
14+ }
1215 },
1316 "errors" : {},
1417 "dependencies" : {}
Original file line number Diff line number Diff line change 1+ import { ScriptContext } from "../module.gen.ts" ;
2+ import { createHypertable } from "../utils/hypertable_init.ts" ;
3+
4+ export interface Request {
5+ name : string ,
6+ metadata : any ,
7+ timestampOverride ?: string ,
8+ }
9+
10+ export interface Response {
11+ id : string ,
12+ timestamp : number ,
13+ }
14+
15+ export async function run (
16+ ctx : ScriptContext ,
17+ req : Request ,
18+ ) : Promise < Response > {
19+ createHypertable ( ctx ) ;
20+ const timestamp = req . timestampOverride ? new Date ( req . timestampOverride ) : new Date ( ) ;
21+ const event = await ctx . db . event . create ( {
22+ data : {
23+ name : req . name ,
24+ timestamp,
25+ metadata : req . metadata
26+ }
27+ } ) ;
28+
29+ return { id : event . id , timestamp : timestamp . getTime ( ) } ;
30+ }
31+
Original file line number Diff line number Diff line change 1+ import { ScriptContext } from "../module.gen.ts" ;
2+
3+ let hasDefinitelyRun = false ;
4+ export const createHypertable = async ( ctx : ScriptContext ) => {
5+ if ( hasDefinitelyRun ) return ;
6+
7+ await ctx . db . $queryRaw `SELECT create_hypertable('event', 'timestamp');` ;
8+
9+ hasDefinitelyRun = true ;
10+ }
Original file line number Diff line number Diff line change 1+ {
2+ "lint" : {
3+ "include" : [
4+ " src/"
5+ ],
6+ "exclude" : [
7+ " tests/"
8+ ],
9+ "rules" : {
10+ "exclude" : [
11+ " no-empty-interface" ,
12+ " no-explicit-any" ,
13+ " require-await"
14+ ]
15+ }
16+ },
17+ "fmt" : {
18+ "useTabs" : true
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments