@dbos-inc/create 2.2.10-preview.g90e74a1e32 → 2.3.7-preview

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.
Files changed (52) hide show
  1. package/dist/cli.js +4 -4
  2. package/dist/cli.js.map +1 -1
  3. package/dist/github-create.js +3 -3
  4. package/dist/github-create.js.map +1 -1
  5. package/dist/init.d.ts.map +1 -1
  6. package/dist/init.js +16 -15
  7. package/dist/init.js.map +1 -1
  8. package/package.json +1 -1
  9. package/templates/dbos-drizzle/README.md +1 -1
  10. package/templates/dbos-drizzle/dbos-config.yaml +1 -1
  11. package/templates/dbos-drizzle/drizzle/meta/0000_snapshot.json +1 -1
  12. package/templates/dbos-drizzle/drizzle/meta/_journal.json +1 -1
  13. package/templates/dbos-drizzle/drizzle.config.ts +1 -1
  14. package/templates/dbos-drizzle/eslint.config.js +13 -13
  15. package/templates/dbos-drizzle/jest.config.js +1 -1
  16. package/templates/dbos-drizzle/nodemon.json +0 -1
  17. package/templates/dbos-drizzle/src/operations.test.ts +11 -13
  18. package/templates/dbos-drizzle/src/operations.ts +10 -5
  19. package/templates/dbos-drizzle/src/schema.ts +2 -2
  20. package/templates/dbos-drizzle/start_postgres_docker.js +9 -7
  21. package/templates/dbos-drizzle/tsconfig.json +15 -20
  22. package/templates/dbos-knex/README.md +1 -1
  23. package/templates/dbos-knex/dbos-config.yaml +1 -1
  24. package/templates/dbos-knex/eslint.config.js +13 -13
  25. package/templates/dbos-knex/jest.config.js +1 -1
  26. package/templates/dbos-knex/knexfile.js +3 -3
  27. package/templates/dbos-knex/migrations/20240212161006_create_dbos_hello_tables.js +5 -5
  28. package/templates/dbos-knex/nodemon.json +0 -1
  29. package/templates/dbos-knex/src/main.test.ts +12 -14
  30. package/templates/dbos-knex/src/main.ts +13 -9
  31. package/templates/dbos-knex/start_postgres_docker.js +9 -7
  32. package/templates/dbos-knex/tsconfig.json +15 -20
  33. package/templates/dbos-prisma/README.md +1 -1
  34. package/templates/dbos-prisma/eslint.config.js +13 -13
  35. package/templates/dbos-prisma/generate_env.js +4 -4
  36. package/templates/dbos-prisma/jest.config.js +1 -1
  37. package/templates/dbos-prisma/nodemon.json +5 -7
  38. package/templates/dbos-prisma/src/operations.test.ts +8 -10
  39. package/templates/dbos-prisma/src/operations.ts +8 -6
  40. package/templates/dbos-prisma/start_postgres_docker.js +9 -7
  41. package/templates/dbos-prisma/tsconfig.json +15 -19
  42. package/templates/dbos-typeorm/README.md +1 -1
  43. package/templates/dbos-typeorm/datasource.ts +18 -18
  44. package/templates/dbos-typeorm/entities/DBOSHello.ts +5 -5
  45. package/templates/dbos-typeorm/eslint.config.js +13 -13
  46. package/templates/dbos-typeorm/jest.config.js +1 -1
  47. package/templates/dbos-typeorm/migrations/1714934318136-DBOSHello.ts +10 -9
  48. package/templates/dbos-typeorm/nodemon.json +5 -7
  49. package/templates/dbos-typeorm/src/operations.test.ts +8 -10
  50. package/templates/dbos-typeorm/src/operations.ts +8 -6
  51. package/templates/dbos-typeorm/start_postgres_docker.js +9 -7
  52. package/templates/dbos-typeorm/tsconfig.json +17 -19
@@ -1,10 +1,10 @@
1
- import { DBOS } from "@dbos-inc/dbos-sdk";
2
- import { app, dbos_hello, Hello } from "./main";
3
- import request from "supertest";
1
+ import { DBOS } from '@dbos-inc/dbos-sdk';
2
+ import { app, dbos_hello, Hello } from './main';
3
+ import request from 'supertest';
4
4
 
5
- describe("operations-test", () => {
5
+ describe('operations-test', () => {
6
6
  beforeAll(async () => {
7
- await DBOS.launch({expressApp: app});
7
+ await DBOS.launch({ expressApp: app });
8
8
  });
9
9
 
10
10
  afterAll(async () => {
@@ -14,23 +14,21 @@ describe("operations-test", () => {
14
14
  /**
15
15
  * Test the transaction.
16
16
  */
17
- test("test-transaction", async () => {
18
- const res = await Hello.helloTransaction("dbos");
19
- expect(res).toMatch("Hello, dbos! You have been greeted");
17
+ test('test-transaction', async () => {
18
+ const res = await Hello.helloTransaction('dbos');
19
+ expect(res).toMatch('Hello, dbos! You have been greeted');
20
20
 
21
21
  // Check the greet count.
22
- const rows = await DBOS.executor.queryUserDB("SELECT * FROM dbos_hello WHERE name=$1", ["dbos"]) as dbos_hello[];
22
+ const rows = (await DBOS.executor.queryUserDB('SELECT * FROM dbos_hello WHERE name=$1', ['dbos'])) as dbos_hello[];
23
23
  expect(rows[0].greet_count).toBe(1);
24
24
  });
25
25
 
26
26
  /**
27
27
  * Test the HTTP endpoint.
28
28
  */
29
- test("test-endpoint", async () => {
30
- const res = await request(app).get(
31
- "/greeting/dbos"
32
- );
29
+ test('test-endpoint', async () => {
30
+ const res = await request(app).get('/greeting/dbos');
33
31
  expect(res.statusCode).toBe(200);
34
- expect(res.text).toMatch("Hello, dbos! You have been greeted");
32
+ expect(res.text).toMatch('Hello, dbos! You have been greeted');
35
33
  });
36
34
  });
@@ -4,7 +4,7 @@
4
4
  // It greets visitors and keeps track of how many times each visitor has been greeted.
5
5
 
6
6
  import express, { Request, Response } from 'express';
7
- import { DBOS } from "@dbos-inc/dbos-sdk";
7
+ import { DBOS } from '@dbos-inc/dbos-sdk';
8
8
 
9
9
  export interface dbos_hello {
10
10
  name: string;
@@ -16,7 +16,8 @@ export class Hello {
16
16
  // It retrieves and increments the number of times a user has been greeted.
17
17
  @DBOS.transaction()
18
18
  static async helloTransaction(user: string) {
19
- const query = "INSERT INTO dbos_hello (name, greet_count) VALUES (?, 1) ON CONFLICT (name) DO UPDATE SET greet_count = dbos_hello.greet_count + 1 RETURNING greet_count;";
19
+ const query =
20
+ 'INSERT INTO dbos_hello (name, greet_count) VALUES (?, 1) ON CONFLICT (name) DO UPDATE SET greet_count = dbos_hello.greet_count + 1 RETURNING greet_count;';
20
21
  const { rows } = (await DBOS.knexClient.raw(query, [user])) as { rows: dbos_hello[] };
21
22
  const greet_count = rows[0].greet_count;
22
23
  const greeting = `Hello, ${user}! You have been greeted ${greet_count} times.`;
@@ -29,12 +30,13 @@ function readme() {
29
30
  return makeHTML(
30
31
  `Visit the route <code class="bg-gray-100 px-1 rounded">/greeting/{name}</code> to be greeted!<br>
31
32
  For example, visit <code class="bg-gray-100 px-1 rounded"><a href="/greeting/Mike" class="text-blue-600 hover:underline">/greeting/Mike</a></code><br>
32
- The counter increments with each page visit.`
33
+ The counter increments with each page visit.`,
33
34
  );
34
35
  }
35
36
 
36
37
  function makeHTML(message: string) {
37
- const page = `
38
+ const page =
39
+ `
38
40
  <!DOCTYPE html>
39
41
  <html lang="en">
40
42
  <head>
@@ -43,7 +45,9 @@ function makeHTML(message: string) {
43
45
  </head>
44
46
  <body class="font-sans text-gray-800 p-6 max-w-2xl mx-auto">
45
47
  <h1 class="text-3xl font-semibold mb-4">Welcome to DBOS!</h1>
46
- <p class="mt-8 mb-8">` + message + `</p>
48
+ <p class="mt-8 mb-8">` +
49
+ message +
50
+ `</p>
47
51
  <p class="mb-2">
48
52
  To learn how to run this app yourself, visit our
49
53
  <a href="https://docs.dbos.dev/quickstart?language=typescript" class="text-blue-600 hover:underline">Quickstart</a>.
@@ -69,8 +73,8 @@ app.get('/', (req: Request, res: Response) => {
69
73
  app.get('/greeting/:name', (req: Request, res: Response) => {
70
74
  const { name } = req.params;
71
75
  Hello.helloTransaction(name)
72
- .then(result => res.send(result))
73
- .catch(error => {
76
+ .then((result) => res.send(result))
77
+ .catch((error) => {
74
78
  console.error(error);
75
79
  res.status(500).send('Internal Server Error');
76
80
  });
@@ -78,7 +82,7 @@ app.get('/greeting/:name', (req: Request, res: Response) => {
78
82
 
79
83
  // Finally, launch DBOS and start the server
80
84
  async function main() {
81
- await DBOS.launch({expressApp: app});
85
+ await DBOS.launch({ expressApp: app });
82
86
  const PORT = 3000;
83
87
  const ENV = process.env.NODE_ENV || 'development';
84
88
 
@@ -91,4 +95,4 @@ async function main() {
91
95
  // Only start the server when this file is run directly from Node
92
96
  if (require.main === module) {
93
97
  main().catch(console.log);
94
- }
98
+ }
@@ -13,28 +13,30 @@ process.argv.forEach((val, index) => {
13
13
  });
14
14
 
15
15
  if (!process.env.PGPASSWORD) {
16
- console.error("Error: PGPASSWORD is not set.");
16
+ console.error('Error: PGPASSWORD is not set.');
17
17
  process.exit(1);
18
18
  }
19
19
 
20
20
  try {
21
- execSync(`docker run --rm --name=dbos-db --env=POSTGRES_PASSWORD="${process.env.PGPASSWORD}" --env=PGDATA=/var/lib/postgresql/data --volume=/var/lib/postgresql/data -p ${port}:5432 -d sibedge/postgres-plv8`);
22
- console.log("Waiting for PostgreSQL to start...");
21
+ execSync(
22
+ `docker run --rm --name=dbos-db --env=POSTGRES_PASSWORD="${process.env.PGPASSWORD}" --env=PGDATA=/var/lib/postgresql/data --volume=/var/lib/postgresql/data -p ${port}:5432 -d sibedge/postgres-plv8`,
23
+ );
24
+ console.log('Waiting for PostgreSQL to start...');
23
25
 
24
26
  let attempts = 30;
25
27
  const checkDatabase = setInterval(() => {
26
28
  try {
27
29
  execSync('docker exec dbos-db psql -U postgres -c "SELECT 1;"', { stdio: 'ignore' });
28
- console.log("PostgreSQL started!");
30
+ console.log('PostgreSQL started!');
29
31
  clearInterval(checkDatabase);
30
- console.log("Database started successfully!");
32
+ console.log('Database started successfully!');
31
33
  } catch (error) {
32
34
  if (--attempts === 0) {
33
35
  clearInterval(checkDatabase);
34
- console.error("Failed to start PostgreSQL.");
36
+ console.error('Failed to start PostgreSQL.');
35
37
  }
36
38
  }
37
39
  }, 1000);
38
40
  } catch (error) {
39
- console.error("Error starting PostgreSQL in Docker:", error.message);
41
+ console.error('Error starting PostgreSQL in Docker:', error.message);
40
42
  }
@@ -1,25 +1,20 @@
1
1
  /* Visit https://aka.ms/tsconfig to read more about this file */
2
2
  {
3
3
  "compilerOptions": {
4
- "target": "esnext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
5
- "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
6
- "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
7
- "module": "Node16", /* Specify what module code is generated. */
8
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
9
- "declarationMap": true, /* Create sourcemaps for d.ts files. */
10
- "sourceMap": true, /* Create source map files for emitted JavaScript files. */
11
- "outDir": "./dist", /* Specify an output folder for all emitted files. */
12
- "newLine": "lf", /* Set the newline character for emitting files. */
13
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
14
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
15
- "strict": true, /* Enable all strict type-checking options. */
16
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
4
+ "target": "esnext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
5
+ "experimentalDecorators": true /* Enable experimental support for legacy experimental decorators. */,
6
+ "emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */,
7
+ "module": "Node16" /* Specify what module code is generated. */,
8
+ "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
9
+ "declarationMap": true /* Create sourcemaps for d.ts files. */,
10
+ "sourceMap": true /* Create source map files for emitted JavaScript files. */,
11
+ "outDir": "./dist" /* Specify an output folder for all emitted files. */,
12
+ "newLine": "lf" /* Set the newline character for emitting files. */,
13
+ "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
14
+ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
15
+ "strict": true /* Enable all strict type-checking options. */,
16
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
17
17
  },
18
- "include": [ /* Specifies an array of filenames or patterns to include in the program. */
19
- "src"
20
- ],
21
- "exclude": [
22
- "**/*.test.ts",
23
- "dist"
24
- ]
18
+ "include": [/* Specifies an array of filenames or patterns to include in the program. */ "src"],
19
+ "exclude": ["**/*.test.ts", "dist"]
25
20
  }
@@ -18,6 +18,6 @@ Congratulations! You just launched a DBOS application.
18
18
 
19
19
  ## Next Steps
20
20
 
21
- - To add more functionality to this application, modify `src/operations.ts`, then rebuild and restart it. Alternatively, `npm run dev` uses `nodemon` to automatically rebuild and restart the app when source files change, using instructions specified in `nodemon.json`.
21
+ - To add more functionality to this application, modify `src/operations.ts`, then rebuild and restart it. Alternatively, `npm run dev` uses `nodemon` to automatically rebuild and restart the app when source files change, using instructions specified in `nodemon.json`.
22
22
  - For a detailed tutorial, check out the [programming guide](https://docs.dbos.dev/typescript/programming-guide).
23
23
  - To learn more about DBOS, take a look at [the documentation](https://docs.dbos.dev/) or [source code](https://github.com/dbos-inc/dbos-transact-ts).
@@ -1,28 +1,28 @@
1
- const { FlatCompat } = require("@eslint/eslintrc");
2
- const dbosIncEslintPlugin = require("@dbos-inc/eslint-plugin");
3
- const typescriptEslint = require("typescript-eslint");
4
- const typescriptEslintParser = require("@typescript-eslint/parser");
5
- const globals = require("globals");
6
- const js = require("@eslint/js");
1
+ const { FlatCompat } = require('@eslint/eslintrc');
2
+ const dbosIncEslintPlugin = require('@dbos-inc/eslint-plugin');
3
+ const typescriptEslint = require('typescript-eslint');
4
+ const typescriptEslintParser = require('@typescript-eslint/parser');
5
+ const globals = require('globals');
6
+ const js = require('@eslint/js');
7
7
 
8
8
  const compat = new FlatCompat({
9
9
  baseDirectory: __dirname,
10
- recommendedConfig: js.configs.recommended
10
+ recommendedConfig: js.configs.recommended,
11
11
  });
12
12
 
13
13
  module.exports = typescriptEslint.config({
14
- extends: compat.extends("plugin:@dbos-inc/dbosRecommendedConfig"),
15
- plugins: { "@dbos-inc": dbosIncEslintPlugin },
14
+ extends: compat.extends('plugin:@dbos-inc/dbosRecommendedConfig'),
15
+ plugins: { '@dbos-inc': dbosIncEslintPlugin },
16
16
 
17
17
  languageOptions: {
18
18
  parser: typescriptEslintParser,
19
- parserOptions: { project: "./tsconfig.json" },
20
- globals: { ...globals.node, ...globals.es6 }
19
+ parserOptions: { project: './tsconfig.json' },
20
+ globals: { ...globals.node, ...globals.es6 },
21
21
  },
22
22
 
23
23
  rules: {
24
- "no-secrets/no-secrets": ["error", { "tolerance": 5 }]
24
+ 'no-secrets/no-secrets': ['error', { tolerance: 5 }],
25
25
  },
26
26
 
27
- ignores: ["**/*.test.ts"]
27
+ ignores: ['**/*.test.ts'],
28
28
  });
@@ -3,14 +3,14 @@ const fs = require('node:fs');
3
3
  const path = require('node:path');
4
4
 
5
5
  // Load the configuration file
6
- const [dbosConfig, ] = parseConfigFile();
6
+ const [dbosConfig] = parseConfigFile();
7
7
 
8
8
  // Write out the .env file
9
9
  const databaseURL = `postgresql://${dbosConfig.poolConfig.user}:${dbosConfig.poolConfig.password}@${dbosConfig.poolConfig.host}:${dbosConfig.poolConfig.port}/${dbosConfig.poolConfig.database}`;
10
10
 
11
11
  try {
12
12
  fs.writeFileSync(path.join(process.cwd(), 'prisma', '.env'), `DATABASE_URL="${databaseURL}"`);
13
- console.log("Wrote database URL to the prisma/.env file.");
13
+ console.log('Wrote database URL to the prisma/.env file.');
14
14
  } catch (error) {
15
- console.error("Error writing prisma/.env file:", error.message);
16
- }
15
+ console.error('Error writing prisma/.env file:', error.message);
16
+ }
@@ -4,5 +4,5 @@ module.exports = {
4
4
  testEnvironment: 'node',
5
5
  testRegex: '((\\.|/)(test|spec))\\.ts?$',
6
6
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
7
- modulePaths: ["./"],
7
+ modulePaths: ['./'],
8
8
  };
@@ -1,8 +1,6 @@
1
1
  {
2
- "watch": ["src/", "prisma/"],
3
- "ext": "ts,json",
4
- "ignore": ["src/**/*.test.ts"],
5
- "exec": "npm run build && npm run start"
6
- }
7
-
8
-
2
+ "watch": ["src/", "prisma/"],
3
+ "ext": "ts,json",
4
+ "ignore": ["src/**/*.test.ts"],
5
+ "exec": "npm run build && npm run start"
6
+ }
@@ -1,8 +1,8 @@
1
- import { DBOS } from "@dbos-inc/dbos-sdk";
2
- import { Hello } from "./operations";
3
- import request from "supertest";
1
+ import { DBOS } from '@dbos-inc/dbos-sdk';
2
+ import { Hello } from './operations';
3
+ import request from 'supertest';
4
4
 
5
- describe("operations-test", () => {
5
+ describe('operations-test', () => {
6
6
  beforeAll(async () => {
7
7
  await DBOS.launch();
8
8
  await DBOS.launchAppHTTPServer();
@@ -15,12 +15,10 @@ describe("operations-test", () => {
15
15
  /**
16
16
  * Test the HTTP endpoint.
17
17
  */
18
- test("test-greet", async () => {
19
- const res = await request(DBOS.getHTTPHandlersCallback()!).get(
20
- "/greeting/dbos"
21
- );
18
+ test('test-greet', async () => {
19
+ const res = await request(DBOS.getHTTPHandlersCallback()!).get('/greeting/dbos');
22
20
  expect(res.statusCode).toBe(200);
23
- expect(res.text).toMatch("Greeting 1: Hello, dbos!");
24
- expect (await Hello.helloTransaction('bob')).toMatch("Greeting 2: Hello, bob!");
21
+ expect(res.text).toMatch('Greeting 1: Hello, dbos!');
22
+ expect(await Hello.helloTransaction('bob')).toMatch('Greeting 2: Hello, bob!');
25
23
  });
26
24
  });
@@ -5,14 +5,13 @@
5
5
 
6
6
  import { DBOS } from '@dbos-inc/dbos-sdk';
7
7
 
8
- import { PrismaClient } from "@prisma/client";
8
+ import { PrismaClient } from '@prisma/client';
9
9
 
10
10
  export class Hello {
11
-
12
11
  // Serve this function from HTTP GET requests at the /greeting endpoint with 'name' as a path parameter
13
12
  @DBOS.getApi('/greeting/:name')
14
13
  @DBOS.transaction()
15
- static async helloTransaction(name: string) {
14
+ static async helloTransaction(name: string) {
16
15
  const greeting = `Hello, ${name}!`;
17
16
  const res = await (DBOS.prismaClient as PrismaClient).dbosHello.create({
18
17
  data: {
@@ -29,14 +28,15 @@ export class Hello {
29
28
  const message = Hello.makeHTML(
30
29
  `Visit the route <code class="bg-gray-100 px-1 rounded">/greeting/{name}</code> to be greeted!<br>
31
30
  For example, visit <code class="bg-gray-100 px-1 rounded"><a href="/greeting/Mike" class="text-blue-600 hover:underline">/greeting/Mike</a></code><br>
32
- The counter increments with each page visit.`
31
+ The counter increments with each page visit.`,
33
32
  );
34
33
  return Promise.resolve(message);
35
34
  }
36
35
 
37
36
  // A helper function to create HTML pages with some styling
38
37
  static makeHTML(message: string) {
39
- const page = `
38
+ const page =
39
+ `
40
40
  <!DOCTYPE html>
41
41
  <html lang="en">
42
42
  <head>
@@ -45,7 +45,9 @@ export class Hello {
45
45
  </head>
46
46
  <body class="font-sans text-gray-800 p-6 max-w-2xl mx-auto">
47
47
  <h1 class="text-3xl font-semibold mb-4">Welcome to DBOS!</h1>
48
- <p class="mt-8 mb-8">` + message + `</p>
48
+ <p class="mt-8 mb-8">` +
49
+ message +
50
+ `</p>
49
51
  <p class="mb-2">
50
52
  This is the Prisma quickstart template app. Read the documentation for it <a href="https://docs.dbos.dev/typescript/tutorials/using-prisma" class="text-blue-600 hover:underline">here</a>.
51
53
  </p>
@@ -13,28 +13,30 @@ process.argv.forEach((val, index) => {
13
13
  });
14
14
 
15
15
  if (!process.env.PGPASSWORD) {
16
- console.error("Error: PGPASSWORD is not set.");
16
+ console.error('Error: PGPASSWORD is not set.');
17
17
  process.exit(1);
18
18
  }
19
19
 
20
20
  try {
21
- execSync(`docker run --rm --name=dbos-db --env=POSTGRES_PASSWORD="${process.env.PGPASSWORD}" --env=PGDATA=/var/lib/postgresql/data --volume=/var/lib/postgresql/data -p ${port}:5432 -d sibedge/postgres-plv8`);
22
- console.log("Waiting for PostgreSQL to start...");
21
+ execSync(
22
+ `docker run --rm --name=dbos-db --env=POSTGRES_PASSWORD="${process.env.PGPASSWORD}" --env=PGDATA=/var/lib/postgresql/data --volume=/var/lib/postgresql/data -p ${port}:5432 -d sibedge/postgres-plv8`,
23
+ );
24
+ console.log('Waiting for PostgreSQL to start...');
23
25
 
24
26
  let attempts = 30;
25
27
  const checkDatabase = setInterval(() => {
26
28
  try {
27
29
  execSync('docker exec dbos-db psql -U postgres -c "SELECT 1;"', { stdio: 'ignore' });
28
- console.log("PostgreSQL started!");
30
+ console.log('PostgreSQL started!');
29
31
  clearInterval(checkDatabase);
30
- console.log("Database started successfully!");
32
+ console.log('Database started successfully!');
31
33
  } catch (error) {
32
34
  if (--attempts === 0) {
33
35
  clearInterval(checkDatabase);
34
- console.error("Failed to start PostgreSQL.");
36
+ console.error('Failed to start PostgreSQL.');
35
37
  }
36
38
  }
37
39
  }, 1000);
38
40
  } catch (error) {
39
- console.error("Error starting PostgreSQL in Docker:", error.message);
41
+ console.error('Error starting PostgreSQL in Docker:', error.message);
40
42
  }
@@ -1,24 +1,20 @@
1
1
  /* Visit https://aka.ms/tsconfig to read more about this file */
2
2
  {
3
3
  "compilerOptions": {
4
- "target": "esnext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
5
- "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
6
- "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
7
- "module": "Node16", /* Specify what module code is generated. */
8
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
9
- "declarationMap": true, /* Create sourcemaps for d.ts files. */
10
- "sourceMap": true, /* Create source map files for emitted JavaScript files. */
11
- "outDir": "./dist", /* Specify an output folder for all emitted files. */
12
- "newLine": "lf", /* Set the newline character for emitting files. */
13
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
14
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
15
- "strict": true, /* Enable all strict type-checking options. */
16
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
4
+ "target": "esnext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
5
+ "experimentalDecorators": true /* Enable experimental support for legacy experimental decorators. */,
6
+ "emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */,
7
+ "module": "Node16" /* Specify what module code is generated. */,
8
+ "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
9
+ "declarationMap": true /* Create sourcemaps for d.ts files. */,
10
+ "sourceMap": true /* Create source map files for emitted JavaScript files. */,
11
+ "outDir": "./dist" /* Specify an output folder for all emitted files. */,
12
+ "newLine": "lf" /* Set the newline character for emitting files. */,
13
+ "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
14
+ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
15
+ "strict": true /* Enable all strict type-checking options. */,
16
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
17
17
  },
18
- "include": [ /* Specifies an array of filenames or patterns to include in the program. */
19
- "src",
20
- ],
21
- "exclude": [
22
- "**/*.test.ts",
23
- ]
18
+ "include": [/* Specifies an array of filenames or patterns to include in the program. */ "src"],
19
+ "exclude": ["**/*.test.ts"]
24
20
  }
@@ -18,6 +18,6 @@ Congratulations! You just launched a DBOS application.
18
18
 
19
19
  ## Next Steps
20
20
 
21
- - To add more functionality to this application, modify `src/main.ts`, then rebuild and restart it. Alternatively, `npm run dev` uses `nodemon` to automatically rebuild and restart the app when source files change, using instructions specified in `nodemon.json`.
21
+ - To add more functionality to this application, modify `src/main.ts`, then rebuild and restart it. Alternatively, `npm run dev` uses `nodemon` to automatically rebuild and restart the app when source files change, using instructions specified in `nodemon.json`.
22
22
  - For a detailed tutorial, check out the [programming guide](https://docs.dbos.dev/typescript/programming-guide).
23
23
  - To learn more about DBOS, take a look at [the documentation](https://docs.dbos.dev/) or [source code](https://github.com/dbos-inc/dbos-transact-ts).
@@ -1,27 +1,27 @@
1
1
  import { parseConfigFile } from '@dbos-inc/dbos-sdk';
2
2
  import { TlsOptions } from 'tls';
3
- import { DataSource } from "typeorm";
3
+ import { DataSource } from 'typeorm';
4
4
 
5
- const [dbosConfig, ] = parseConfigFile();
5
+ const [dbosConfig] = parseConfigFile();
6
6
 
7
7
  const AppDataSource = new DataSource({
8
- type: 'postgres',
9
- host: dbosConfig.poolConfig.host,
10
- port: dbosConfig.poolConfig.port,
11
- username: dbosConfig.poolConfig.user,
12
- password: dbosConfig.poolConfig.password as string,
13
- database: dbosConfig.poolConfig.database,
14
- ssl: dbosConfig.poolConfig.ssl as TlsOptions,
15
- entities: ['dist/entities/*.js'],
16
- migrations: ['dist/migrations/*.js'],
8
+ type: 'postgres',
9
+ host: dbosConfig.poolConfig.host,
10
+ port: dbosConfig.poolConfig.port,
11
+ username: dbosConfig.poolConfig.user,
12
+ password: dbosConfig.poolConfig.password as string,
13
+ database: dbosConfig.poolConfig.database,
14
+ ssl: dbosConfig.poolConfig.ssl as TlsOptions,
15
+ entities: ['dist/entities/*.js'],
16
+ migrations: ['dist/migrations/*.js'],
17
17
  });
18
18
 
19
19
  AppDataSource.initialize()
20
- .then(() => {
21
- console.log("Data Source has been initialized!");
22
- })
23
- .catch((err) => {
24
- console.error("Error during Data Source initialization", err);
25
- });
20
+ .then(() => {
21
+ console.log('Data Source has been initialized!');
22
+ })
23
+ .catch((err) => {
24
+ console.error('Error during Data Source initialization', err);
25
+ });
26
26
 
27
- export default AppDataSource;
27
+ export default AppDataSource;
@@ -1,10 +1,10 @@
1
- import { Entity, PrimaryGeneratedColumn, Column } from "typeorm";
1
+ import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
2
2
 
3
3
  @Entity()
4
4
  export class DBOSHello {
5
- @PrimaryGeneratedColumn()
6
- greeting_id: number = 0;
5
+ @PrimaryGeneratedColumn()
6
+ greeting_id: number = 0;
7
7
 
8
- @Column()
9
- greeting: string = "greeting";
8
+ @Column()
9
+ greeting: string = 'greeting';
10
10
  }
@@ -1,28 +1,28 @@
1
- const { FlatCompat } = require("@eslint/eslintrc");
2
- const dbosIncEslintPlugin = require("@dbos-inc/eslint-plugin");
3
- const typescriptEslint = require("typescript-eslint");
4
- const typescriptEslintParser = require("@typescript-eslint/parser");
5
- const globals = require("globals");
6
- const js = require("@eslint/js");
1
+ const { FlatCompat } = require('@eslint/eslintrc');
2
+ const dbosIncEslintPlugin = require('@dbos-inc/eslint-plugin');
3
+ const typescriptEslint = require('typescript-eslint');
4
+ const typescriptEslintParser = require('@typescript-eslint/parser');
5
+ const globals = require('globals');
6
+ const js = require('@eslint/js');
7
7
 
8
8
  const compat = new FlatCompat({
9
9
  baseDirectory: __dirname,
10
- recommendedConfig: js.configs.recommended
10
+ recommendedConfig: js.configs.recommended,
11
11
  });
12
12
 
13
13
  module.exports = typescriptEslint.config({
14
- extends: compat.extends("plugin:@dbos-inc/dbosRecommendedConfig"),
15
- plugins: { "@dbos-inc": dbosIncEslintPlugin },
14
+ extends: compat.extends('plugin:@dbos-inc/dbosRecommendedConfig'),
15
+ plugins: { '@dbos-inc': dbosIncEslintPlugin },
16
16
 
17
17
  languageOptions: {
18
18
  parser: typescriptEslintParser,
19
- parserOptions: { project: "./tsconfig.json" },
20
- globals: { ...globals.node, ...globals.es6 }
19
+ parserOptions: { project: './tsconfig.json' },
20
+ globals: { ...globals.node, ...globals.es6 },
21
21
  },
22
22
 
23
23
  rules: {
24
- "no-secrets/no-secrets": ["error", { "tolerance": 5 }]
24
+ 'no-secrets/no-secrets': ['error', { tolerance: 5 }],
25
25
  },
26
26
 
27
- ignores: ["**/*.test.ts"]
27
+ ignores: ['**/*.test.ts'],
28
28
  });
@@ -4,5 +4,5 @@ module.exports = {
4
4
  testEnvironment: 'node',
5
5
  testRegex: '((\\.|/)(test|spec))\\.ts?$',
6
6
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
7
- modulePaths: ["./"],
7
+ modulePaths: ['./'],
8
8
  };
@@ -1,4 +1,4 @@
1
- import { MigrationInterface, QueryRunner } from "typeorm";
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
2
 
3
3
  // This migration file was automatically generated from the project entity files (entities/*.ts).
4
4
  // This was done by running on an empty database the command: `npx typeorm migration:generate -d dist/datasource.js migrations/DBOSHello`
@@ -6,14 +6,15 @@ import { MigrationInterface, QueryRunner } from "typeorm";
6
6
  // For more information on schema management with TypeORM and DBOS, see our docs: https://docs.dbos.dev/tutorials/using-typeorm
7
7
 
8
8
  export class DBOSHello1714934318136 implements MigrationInterface {
9
- name = 'DBOSHello1714934318136';
9
+ name = 'DBOSHello1714934318136';
10
10
 
11
- public async up(queryRunner: QueryRunner): Promise<void> {
12
- await queryRunner.query(`CREATE TABLE "dbos_hello" ("greeting_id" SERIAL NOT NULL, "greeting" character varying NOT NULL, CONSTRAINT "PK_12681863ff5f1fd5ea35f185b51" PRIMARY KEY ("greeting_id"))`);
13
- }
14
-
15
- public async down(queryRunner: QueryRunner): Promise<void> {
16
- await queryRunner.query(`DROP TABLE "dbos_hello"`);
17
- }
11
+ public async up(queryRunner: QueryRunner): Promise<void> {
12
+ await queryRunner.query(
13
+ `CREATE TABLE "dbos_hello" ("greeting_id" SERIAL NOT NULL, "greeting" character varying NOT NULL, CONSTRAINT "PK_12681863ff5f1fd5ea35f185b51" PRIMARY KEY ("greeting_id"))`,
14
+ );
15
+ }
18
16
 
17
+ public async down(queryRunner: QueryRunner): Promise<void> {
18
+ await queryRunner.query(`DROP TABLE "dbos_hello"`);
19
+ }
19
20
  }
@@ -1,8 +1,6 @@
1
1
  {
2
- "watch": ["src/", "entities/"],
3
- "ext": "ts,json",
4
- "ignore": ["src/**/*.test.ts"],
5
- "exec": "npm run build && npm run start"
6
- }
7
-
8
-
2
+ "watch": ["src/", "entities/"],
3
+ "ext": "ts,json",
4
+ "ignore": ["src/**/*.test.ts"],
5
+ "exec": "npm run build && npm run start"
6
+ }