create-stb 1.0.6 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,67 +0,0 @@
1
- import { getClient, listTables, tableExists, createTable } from "../lib/dynamodb";
2
-
3
- /**
4
- * List of table configs to create.
5
- * Extend this array to add more generic example tables.
6
- */
7
- const tables = [
8
- {
9
- TableName: "Example",
10
- AttributeDefinitions: [{ AttributeName: "id", AttributeType: "S" }],
11
- KeySchema: [{ AttributeName: "id", KeyType: "HASH" }],
12
- BillingMode: "PAY_PER_REQUEST",
13
- },
14
- ];
15
-
16
- async function createTables(): Promise<void> {
17
- console.log("šŸ—ļø Creating DynamoDB tables (Docker/local)...\n");
18
-
19
- // Use the client provided by your library (env config, singleton, etc.)
20
- const client = getClient();
21
-
22
- try {
23
- const existingTables = await listTables(client);
24
- console.log("Existing tables:", existingTables);
25
- console.log("");
26
-
27
- for (const tableConfig of tables) {
28
- const { TableName } = tableConfig;
29
-
30
- if (!TableName) {
31
- console.error("āŒ Table config missing TableName:", tableConfig);
32
- continue;
33
- }
34
-
35
- try {
36
- const exists = await tableExists(client, TableName);
37
- if (exists) {
38
- console.log(`āœ… Table '${TableName}' already exists`);
39
- } else {
40
- console.log(`Creating table '${TableName}'...`);
41
- await createTable(client, tableConfig);
42
- console.log(`āœ… Table '${TableName}' created successfully`);
43
- }
44
- } catch (error: any) {
45
- if (error?.name === "ResourceInUseException") {
46
- console.log(`āœ… Table '${TableName}' already exists (AWS error)`);
47
- } else {
48
- console.error(`āŒ Failed to create table '${TableName}':`, error?.message ?? error);
49
- }
50
- }
51
- }
52
-
53
- console.log("\nšŸŽ‰ Table creation complete!");
54
- console.log("šŸ“Š Check your tables at: http://localhost:8001\n");
55
- } catch (error: any) {
56
- console.error("āŒ Error in table creation process:", error?.message ?? error);
57
- process.exit(1);
58
- }
59
- }
60
-
61
- createTables();
62
-
63
- /**
64
- * Usage:
65
- * Run this script after starting local DynamoDB (Docker or otherwise).
66
- * Edit `tables` to add/remove demo tables. All configuration is managed by your central DynamoDB utility (`lib/dynamodb.ts`).
67
- */
@@ -1,25 +0,0 @@
1
- import { generatePlainExamples } from "../functions/example";
2
- import { Tables } from "../types";
3
- import { generateAndSeed } from "../lib/seed";
4
- import { getClient, putItem } from "../lib/dynamodb";
5
-
6
- async function seedAllTables(): Promise<void> {
7
- try {
8
- console.log("🌱 Starting database seeding...\n");
9
- const client = getClient();
10
-
11
- const put = (tableName: string, item: any) => putItem(client, tableName, item);
12
-
13
- const example = await generateAndSeed(put, Tables.Example, generatePlainExamples);
14
-
15
- console.log("šŸŽ‰ Database seeding complete!");
16
- console.log("šŸ“Š Final data counts:");
17
- console.log(` - Example: ${example.length}\n`);
18
- console.log("View data at: http://localhost:8001");
19
- } catch (error) {
20
- console.error("āŒ Error seeding database:", error);
21
- process.exit(1);
22
- }
23
- }
24
-
25
- seedAllTables();
@@ -1,7 +0,0 @@
1
- export enum Tables {
2
- Example = "Example",
3
- }
4
-
5
- export interface Example {
6
- id: string;
7
- }
@@ -1,4 +0,0 @@
1
- export const shortUUID = (): string => {
2
- const uuid = crypto.randomUUID();
3
- return uuid.slice(0, 8);
4
- };
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2020",
4
- "module": "commonjs",
5
- "outDir": ".build",
6
- "rootDir": "src",
7
- "strict": true,
8
- "esModuleInterop": true,
9
- "forceConsistentCasingInFileNames": true,
10
- "moduleResolution": "node",
11
- "resolveJsonModule": true,
12
- "lib": ["es2020"],
13
- "skipLibCheck": true,
14
- "sourceMap": true,
15
- "types": ["node", "aws-lambda"]
16
- },
17
- "include": ["src/**/*.ts"],
18
- "exclude": ["node_modules", ".build", ".serverless"]
19
- }