@dbos-inc/create 2.2.10-preview.g90e74a1e32 → 2.3.9-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.
- package/dist/cli.js +4 -4
- package/dist/cli.js.map +1 -1
- package/dist/github-create.js +3 -3
- package/dist/github-create.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +16 -15
- package/dist/init.js.map +1 -1
- package/package.json +1 -1
- package/templates/dbos-drizzle/README.md +1 -1
- package/templates/dbos-drizzle/dbos-config.yaml +1 -1
- package/templates/dbos-drizzle/drizzle/meta/0000_snapshot.json +1 -1
- package/templates/dbos-drizzle/drizzle/meta/_journal.json +1 -1
- package/templates/dbos-drizzle/drizzle.config.ts +1 -1
- package/templates/dbos-drizzle/eslint.config.js +13 -13
- package/templates/dbos-drizzle/jest.config.js +1 -1
- package/templates/dbos-drizzle/nodemon.json +0 -1
- package/templates/dbos-drizzle/src/operations.test.ts +11 -13
- package/templates/dbos-drizzle/src/operations.ts +10 -5
- package/templates/dbos-drizzle/src/schema.ts +2 -2
- package/templates/dbos-drizzle/start_postgres_docker.js +9 -7
- package/templates/dbos-drizzle/tsconfig.json +15 -20
- package/templates/dbos-knex/README.md +1 -1
- package/templates/dbos-knex/dbos-config.yaml +1 -1
- package/templates/dbos-knex/eslint.config.js +13 -13
- package/templates/dbos-knex/jest.config.js +1 -1
- package/templates/dbos-knex/knexfile.js +3 -3
- package/templates/dbos-knex/migrations/20240212161006_create_dbos_hello_tables.js +5 -5
- package/templates/dbos-knex/nodemon.json +0 -1
- package/templates/dbos-knex/src/main.test.ts +12 -14
- package/templates/dbos-knex/src/main.ts +13 -9
- package/templates/dbos-knex/start_postgres_docker.js +9 -7
- package/templates/dbos-knex/tsconfig.json +15 -20
- package/templates/dbos-prisma/README.md +1 -1
- package/templates/dbos-prisma/eslint.config.js +13 -13
- package/templates/dbos-prisma/generate_env.js +4 -4
- package/templates/dbos-prisma/jest.config.js +1 -1
- package/templates/dbos-prisma/nodemon.json +5 -7
- package/templates/dbos-prisma/src/operations.test.ts +8 -10
- package/templates/dbos-prisma/src/operations.ts +8 -6
- package/templates/dbos-prisma/start_postgres_docker.js +9 -7
- package/templates/dbos-prisma/tsconfig.json +15 -19
- package/templates/dbos-typeorm/README.md +1 -1
- package/templates/dbos-typeorm/datasource.ts +18 -18
- package/templates/dbos-typeorm/entities/DBOSHello.ts +5 -5
- package/templates/dbos-typeorm/eslint.config.js +13 -13
- package/templates/dbos-typeorm/jest.config.js +1 -1
- package/templates/dbos-typeorm/migrations/1714934318136-DBOSHello.ts +10 -9
- package/templates/dbos-typeorm/nodemon.json +5 -7
- package/templates/dbos-typeorm/src/operations.test.ts +8 -10
- package/templates/dbos-typeorm/src/operations.ts +8 -6
- package/templates/dbos-typeorm/start_postgres_docker.js +9 -7
- package/templates/dbos-typeorm/tsconfig.json +17 -19
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DBOS } from
|
|
2
|
-
import { Hello } from
|
|
3
|
-
import request from
|
|
1
|
+
import { DBOS } from '@dbos-inc/dbos-sdk';
|
|
2
|
+
import { Hello } from './operations';
|
|
3
|
+
import request from 'supertest';
|
|
4
4
|
|
|
5
|
-
describe(
|
|
5
|
+
describe('operations-test', () => {
|
|
6
6
|
beforeAll(async () => {
|
|
7
7
|
await DBOS.launch();
|
|
8
8
|
await DBOS.launchAppHTTPServer();
|
|
@@ -15,13 +15,11 @@ describe("operations-test", () => {
|
|
|
15
15
|
/**
|
|
16
16
|
* Test the HTTP endpoint.
|
|
17
17
|
*/
|
|
18
|
-
test(
|
|
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(
|
|
21
|
+
expect(res.text).toMatch('Greeting 1: Hello, dbos!');
|
|
24
22
|
|
|
25
|
-
expect(await Hello.helloTransaction('bob')).toMatch(
|
|
23
|
+
expect(await Hello.helloTransaction('bob')).toMatch('Greeting 2: Hello, bob!');
|
|
26
24
|
});
|
|
27
25
|
});
|
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
// To learn how to run this app, visit the TypeORM tutorial: https://docs.dbos.dev/tutorials/using-typeorm
|
|
5
5
|
|
|
6
6
|
import { DBOS, OrmEntities } from '@dbos-inc/dbos-sdk';
|
|
7
|
-
import { EntityManager } from
|
|
7
|
+
import { EntityManager } from 'typeorm';
|
|
8
8
|
import { DBOSHello } from '../entities/DBOSHello';
|
|
9
9
|
|
|
10
10
|
@OrmEntities([DBOSHello])
|
|
11
11
|
export class Hello {
|
|
12
|
-
|
|
13
12
|
@DBOS.getApi('/greeting/:name')
|
|
14
13
|
@DBOS.transaction()
|
|
15
14
|
static async helloTransaction(name: string) {
|
|
@@ -17,7 +16,7 @@ export class Hello {
|
|
|
17
16
|
let entity = new DBOSHello();
|
|
18
17
|
entity.greeting = greeting;
|
|
19
18
|
entity = await (DBOS.typeORMClient as EntityManager).save(entity);
|
|
20
|
-
const greeting_note =
|
|
19
|
+
const greeting_note = `Greeting ${entity.greeting_id}: ${greeting}`;
|
|
21
20
|
return Hello.makeHTML(greeting_note);
|
|
22
21
|
}
|
|
23
22
|
|
|
@@ -27,14 +26,15 @@ export class Hello {
|
|
|
27
26
|
const message = Hello.makeHTML(
|
|
28
27
|
`Visit the route <code class="bg-gray-100 px-1 rounded">/greeting/{name}</code> to be greeted!<br>
|
|
29
28
|
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>
|
|
30
|
-
The counter increments with each page visit
|
|
29
|
+
The counter increments with each page visit.`,
|
|
31
30
|
);
|
|
32
31
|
return Promise.resolve(message);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
// A helper function to create HTML pages with some styling
|
|
36
35
|
static makeHTML(message: string) {
|
|
37
|
-
const page =
|
|
36
|
+
const page =
|
|
37
|
+
`
|
|
38
38
|
<!DOCTYPE html>
|
|
39
39
|
<html lang="en">
|
|
40
40
|
<head>
|
|
@@ -43,7 +43,9 @@ export class Hello {
|
|
|
43
43
|
</head>
|
|
44
44
|
<body class="font-sans text-gray-800 p-6 max-w-2xl mx-auto">
|
|
45
45
|
<h1 class="text-3xl font-semibold mb-4">Welcome to DBOS!</h1>
|
|
46
|
-
<p class="mt-8 mb-8">` +
|
|
46
|
+
<p class="mt-8 mb-8">` +
|
|
47
|
+
message +
|
|
48
|
+
`</p>
|
|
47
49
|
<p class="mb-2">
|
|
48
50
|
This is the TypeORM quickstart template app. Read the documentation for it <a href="https://docs.dbos.dev/typescript/tutorials/using-typeorm" class="text-blue-600 hover:underline">here</a>.
|
|
49
51
|
</p>
|
|
@@ -13,28 +13,30 @@ process.argv.forEach((val, index) => {
|
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
if (!process.env.PGPASSWORD) {
|
|
16
|
-
console.error(
|
|
16
|
+
console.error('Error: PGPASSWORD is not set.');
|
|
17
17
|
process.exit(1);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
try {
|
|
21
|
-
execSync(
|
|
22
|
-
|
|
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(
|
|
30
|
+
console.log('PostgreSQL started!');
|
|
29
31
|
clearInterval(checkDatabase);
|
|
30
|
-
console.log(
|
|
32
|
+
console.log('Database started successfully!');
|
|
31
33
|
} catch (error) {
|
|
32
34
|
if (--attempts === 0) {
|
|
33
35
|
clearInterval(checkDatabase);
|
|
34
|
-
console.error(
|
|
36
|
+
console.error('Failed to start PostgreSQL.');
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
}, 1000);
|
|
38
40
|
} catch (error) {
|
|
39
|
-
console.error(
|
|
41
|
+
console.error('Error starting PostgreSQL in Docker:', error.message);
|
|
40
42
|
}
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
2
2
|
{
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"target": "esnext"
|
|
5
|
-
"experimentalDecorators": true
|
|
6
|
-
"emitDecoratorMetadata": true
|
|
7
|
-
"module": "Node16"
|
|
8
|
-
"declaration": true
|
|
9
|
-
"declarationMap": true
|
|
10
|
-
"sourceMap": true
|
|
11
|
-
"outDir": "./dist"
|
|
12
|
-
"newLine": "lf"
|
|
13
|
-
"esModuleInterop": true
|
|
14
|
-
"forceConsistentCasingInFileNames": true
|
|
15
|
-
"strict": true
|
|
16
|
-
"skipLibCheck": true
|
|
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": [
|
|
19
|
-
"datasource.ts",
|
|
18
|
+
"include": [
|
|
19
|
+
/* Specifies an array of filenames or patterns to include in the program. */ "datasource.ts",
|
|
20
20
|
"src",
|
|
21
21
|
"entities",
|
|
22
|
-
"migrations"
|
|
22
|
+
"migrations"
|
|
23
23
|
],
|
|
24
|
-
"exclude": [
|
|
25
|
-
"**/*.test.ts",
|
|
26
|
-
]
|
|
24
|
+
"exclude": ["**/*.test.ts"]
|
|
27
25
|
}
|