this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: store consumer name into variable

+29 -7
+1
receiver.go
··· 10 10 11 11 const StreamName = "notella:stream" 12 12 const SubjectName = "notella:notification" 13 + const ConsumerName = "NotellaConsumer" 13 14 14 15 func NatsReceiver(m jetstream.Msg) error { 15 16 var message Message
+18 -1
scripts/typing.go
··· 30 30 31 31 // Also save useful constants 32 32 ll.Log("Writing", "cyan", "exported constants") 33 - os.WriteFile("typescript/constants.ts", []byte(fmt.Sprintf("export const STREAM_NAME = '%s';\nexport const SUBJECT_NAME = '%s';\n", notella.StreamName, notella.SubjectName)), 0644) 33 + os.WriteFile("typescript/constants.ts", printTypescriptConstants( 34 + constant{"STREAM_NAME", notella.StreamName}, 35 + constant{"SUBJECT_NAME", notella.SubjectName}, 36 + constant{"CONSUMER_NAME", notella.ConsumerName}, 37 + ), 0644) 34 38 35 39 // Write barrel 36 40 ll.Log("Writing", "cyan", "barrel file") ··· 86 90 return "" 87 91 } 88 92 return fmt.Sprintf("[blue]%s:%d:%d[reset]", loc.File, loc.Line, loc.Column) 93 + } 94 + 95 + type constant struct { 96 + name string 97 + value string 98 + } 99 + 100 + func printTypescriptConstants(declarations ...constant) []byte { 101 + lines := make([]string, 0, len(declarations)) 102 + for _, decl := range declarations { 103 + lines = append(lines, fmt.Sprintf("export const %s = '%s';", decl.name, decl.value)) 104 + } 105 + return []byte(strings.Join(lines, "\n")) 89 106 } 90 107 91 108 func writeTypescriptDefinition(reflector *jsonschema.Reflector, typename string, typ interface{}, filename string) {
+4 -4
server/main.go
··· 95 95 return 96 96 } 97 97 98 - ll.Log("Initializing", "cyan", "Jetstream consumer [bold]NotellaConsumer[reset] with [bold]AckExplicitPolicy[reset]") 98 + ll.Log("Initializing", "cyan", "Jetstream consumer [bold]%s[reset] with [bold]AckExplicitPolicy[reset]", notella.ConsumerName) 99 99 100 100 consumer, err := stream.CreateConsumer(ctx, jetstream.ConsumerConfig{ 101 - Durable: "NotellaConsumer", 102 - Name: "NotellaConsumer", 101 + Durable: notella.ConsumerName, 102 + Name: notella.ConsumerName, 103 103 AckPolicy: jetstream.AckExplicitPolicy, 104 104 }) 105 105 if err != nil { ··· 107 107 return 108 108 } 109 109 110 - ll.Log("Starting", "cyan", "consumer [bold]NotellaConsumer[reset]") 110 + ll.Log("Starting", "cyan", "consumer [bold]%s[reset]", notella.ConsumerName) 111 111 112 112 cc, err := consumer.Consume( 113 113 func(msg jetstream.Msg) {
+2
typescript-dist/index.js
··· 25 25 // typescript/constants.ts 26 26 var STREAM_NAME = "notella:stream"; 27 27 var SUBJECT_NAME = "notella:notification"; 28 + var CONSUMER_NAME = "NotellaConsumer"; 28 29 export { 30 + CONSUMER_NAME, 29 31 Event, 30 32 STREAM_NAME, 31 33 SUBJECT_NAME
+2 -2
typescript-dist/index.js.map
··· 1 1 { 2 2 "version": 3, 3 3 "sources": ["../typescript/message.ts", "../typescript/constants.ts"], 4 - "sourcesContent": ["export interface Message {\n /**\n * URL to go to when the action button is clicked\n */\n action: string;\n /**\n * Additional action buttons\n */\n actions?: Action[];\n /**\n * Notification body\n */\n body: string;\n /**\n * Type of event that triggered the notification\n * next-line-generate event-enum-jsonschema-values\n */\n event: Event;\n /**\n * Unique ID for the notification scheduling request.\n */\n id: string;\n /**\n * URL to an image to display in the notification\n */\n image?: string;\n /**\n * Churros ID of the ressource (the ticket, the post, the comment, etc)\n * Used to determine to whom the notification should be sent\n * For godchild_request, this is not a user id, but a godparent request id.\n */\n object_id: string;\n /**\n * When to push the notification\n */\n send_at: Date;\n /**\n * Notification title\n */\n title: string;\n}\n\nexport interface Action {\n action: string;\n label: string;\n}\n\n/**\n * Type of event that triggered the notification\n * next-line-generate event-enum-jsonschema-values\n */\nexport enum Event {\n BookingPaid = \"booking_paid\",\n ClearSchedule = \"clear_schedule\",\n ClearScheduledJobs = \"clear_scheduled_jobs\",\n ClearStoredSchedule = \"clear_stored_schedule\",\n ContributionPaid = \"contribution_paid\",\n Custom = \"custom\",\n GodchildAccepted = \"godchild_accepted\",\n GodchildRejected = \"godchild_rejected\",\n GodchildRequest = \"godchild_request\",\n LoginStuck = \"login_stuck\",\n NewPost = \"new_post\",\n PendingSignup = \"pending_signup\",\n RestoreSchedule = \"restore_schedule\",\n RestoreScheduleEager = \"restore_schedule_eager\",\n SaveSchedule = \"save_schedule\",\n ShotgunClosesSoon = \"shotgun_closes_soon\",\n ShotgunOpensSoon = \"shotgun_opens_soon\",\n ShowScheduledJobs = \"show_scheduled_jobs\",\n Test = \"test\",\n}\n", "export const STREAM_NAME = 'notella:stream';\nexport const SUBJECT_NAME = 'notella:notification';\n"], 5 - "mappings": ";AAmDO,IAAK,QAAL,kBAAKA,WAAL;AACH,EAAAA,OAAA,iBAAc;AACd,EAAAA,OAAA,mBAAgB;AAChB,EAAAA,OAAA,wBAAqB;AACrB,EAAAA,OAAA,yBAAsB;AACtB,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,YAAS;AACT,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,qBAAkB;AAClB,EAAAA,OAAA,gBAAa;AACb,EAAAA,OAAA,aAAU;AACV,EAAAA,OAAA,mBAAgB;AAChB,EAAAA,OAAA,qBAAkB;AAClB,EAAAA,OAAA,0BAAuB;AACvB,EAAAA,OAAA,kBAAe;AACf,EAAAA,OAAA,uBAAoB;AACpB,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,uBAAoB;AACpB,EAAAA,OAAA,UAAO;AAnBC,SAAAA;AAAA,GAAA;;;ACnDL,IAAM,cAAc;AACpB,IAAM,eAAe;", 4 + "sourcesContent": ["export interface Message {\n /**\n * URL to go to when the action button is clicked\n */\n action: string;\n /**\n * Additional action buttons\n */\n actions?: Action[];\n /**\n * Notification body\n */\n body: string;\n /**\n * Type of event that triggered the notification\n * next-line-generate event-enum-jsonschema-values\n */\n event: Event;\n /**\n * Unique ID for the notification scheduling request.\n */\n id: string;\n /**\n * URL to an image to display in the notification\n */\n image?: string;\n /**\n * Churros ID of the ressource (the ticket, the post, the comment, etc)\n * Used to determine to whom the notification should be sent\n * For godchild_request, this is not a user id, but a godparent request id.\n */\n object_id: string;\n /**\n * When to push the notification\n */\n send_at: Date;\n /**\n * Notification title\n */\n title: string;\n}\n\nexport interface Action {\n action: string;\n label: string;\n}\n\n/**\n * Type of event that triggered the notification\n * next-line-generate event-enum-jsonschema-values\n */\nexport enum Event {\n BookingPaid = \"booking_paid\",\n ClearSchedule = \"clear_schedule\",\n ClearScheduledJobs = \"clear_scheduled_jobs\",\n ClearStoredSchedule = \"clear_stored_schedule\",\n ContributionPaid = \"contribution_paid\",\n Custom = \"custom\",\n GodchildAccepted = \"godchild_accepted\",\n GodchildRejected = \"godchild_rejected\",\n GodchildRequest = \"godchild_request\",\n LoginStuck = \"login_stuck\",\n NewPost = \"new_post\",\n PendingSignup = \"pending_signup\",\n RestoreSchedule = \"restore_schedule\",\n RestoreScheduleEager = \"restore_schedule_eager\",\n SaveSchedule = \"save_schedule\",\n ShotgunClosesSoon = \"shotgun_closes_soon\",\n ShotgunOpensSoon = \"shotgun_opens_soon\",\n ShowScheduledJobs = \"show_scheduled_jobs\",\n Test = \"test\",\n}\n", "export const STREAM_NAME = 'notella:stream';\nexport const SUBJECT_NAME = 'notella:notification';\nexport const CONSUMER_NAME = 'NotellaConsumer';"], 5 + "mappings": ";AAmDO,IAAK,QAAL,kBAAKA,WAAL;AACH,EAAAA,OAAA,iBAAc;AACd,EAAAA,OAAA,mBAAgB;AAChB,EAAAA,OAAA,wBAAqB;AACrB,EAAAA,OAAA,yBAAsB;AACtB,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,YAAS;AACT,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,qBAAkB;AAClB,EAAAA,OAAA,gBAAa;AACb,EAAAA,OAAA,aAAU;AACV,EAAAA,OAAA,mBAAgB;AAChB,EAAAA,OAAA,qBAAkB;AAClB,EAAAA,OAAA,0BAAuB;AACvB,EAAAA,OAAA,kBAAe;AACf,EAAAA,OAAA,uBAAoB;AACpB,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,uBAAoB;AACpB,EAAAA,OAAA,UAAO;AAnBC,SAAAA;AAAA,GAAA;;;ACnDL,IAAM,cAAc;AACpB,IAAM,eAAe;AACrB,IAAM,gBAAgB;", 6 6 "names": ["Event"] 7 7 }
+1
typescript/constants.ts
··· 1 1 export const STREAM_NAME = 'notella:stream'; 2 2 export const SUBJECT_NAME = 'notella:notification'; 3 + export const CONSUMER_NAME = 'NotellaConsumer';
+1
typescript/lib.txt
··· 1 1 [Module: null prototype] { 2 + CONSUMER_NAME: 'NotellaConsumer', 2 3 Event: { 3 4 BookingPaid: 'booking_paid', 4 5 ClearSchedule: 'clear_schedule',