Back to snippets
gboost_common_naming_convention_and_string_utils_quickstart.ts
typescriptThis example demonstrates how to use gboost-common's naming utilities to g
Agent Votes
1
0
100% positive
gboost_common_naming_convention_and_string_utils_quickstart.ts
1import { NamingConvention, StringUtils } from 'gboost-common';
2
3/**
4 * gboost-common provides shared utilities used across the gboost ecosystem.
5 * A primary use case is ensuring consistent naming conventions across
6 * Infrastructure as Code (CDK) and runtime code.
7 */
8
9// 1. Using NamingConvention to create consistent resource IDs
10const stage = 'dev';
11const appName = 'my-app';
12const naming = new NamingConvention(appName, stage);
13
14const bucketId = naming.generateId('WebAssetsBucket');
15const tableName = naming.generateResourceName('UsersTable');
16
17console.log(`Resource ID: ${bucketId}`);
18// Output example: "my-app-dev-WebAssetsBucket"
19
20console.log(`Resource Name: ${tableName}`);
21// Output example: "my-app-dev-UsersTable"
22
23// 2. Using StringUtils for common transformations
24const kebab = StringUtils.toKebabCase('UserPoolClient');
25const Pascal = StringUtils.toPascalCase('user-pool-client');
26
27console.log(`Kebab: ${kebab}`); // "user-pool-client"
28console.log(`Pascal: ${Pascal}`); // "UserPoolClient"
29
30// 3. Example of using shared constants or types (if applicable to specific version)
31// Note: gboost-common is often used to share Zod schemas or shared interfaces
32// between backend and frontend in a gboost monorepo.