@dbos-inc/create 1.8.11-preview → 1.8.23-preview.g8060c74f33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbos-inc/create",
3
- "version": "1.8.11-preview",
3
+ "version": "1.8.23-preview.g8060c74f33",
4
4
  "description": "Tool for performing project initialization from template",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -6,23 +6,21 @@ This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/db
6
6
 
7
7
  Before you can launch your app, you need a database.
8
8
  DBOS works with any Postgres database, but to make things easier, we've provided a script that starts a Docker Postgres container and creates a database.
9
- On Linux or Mac, run:
9
+ Run:
10
10
 
11
11
  ```bash
12
- export PGPASSWORD=dbos
13
- ./start_postgres_docker.sh
12
+ node start_postgres_docker.js
14
13
  ```
15
14
 
16
- On Windows (cmd), run:
15
+ If successful, the script should print `Database started successfully!`.
17
16
 
18
- ```cmd
19
- set PGPASSWORD=dbos
20
- start_postgres_docker.bat
21
- ```
17
+ Next, build the app:
22
18
 
23
- If successful, the script should print `Database started successfully!`.
19
+ ```bash
20
+ npm run build
21
+ ```
24
22
 
25
- Then, let's run a schema migration to create some tables:
23
+ Then, run a schema migration to create some tables:
26
24
 
27
25
  ```bash
28
26
  npx dbos-sdk migrate
@@ -30,10 +28,9 @@ npx dbos-sdk migrate
30
28
 
31
29
  If successful, the migration should print `Migration successful!`.
32
30
 
33
- Next, build and run the app:
31
+ Finally, run the app:
34
32
 
35
33
  ```bash
36
- npm run build
37
34
  npx dbos-sdk start
38
35
  ```
39
36
 
@@ -2,6 +2,6 @@
2
2
  "watch": ["src/","migrations/"],
3
3
  "ext": "ts,json",
4
4
  "ignore": ["src/**/*.test.ts"],
5
- "exec": "npm run build && npx knex migrate:up && npm run start"
5
+ "exec": "npm run build && npx dbos migrate && npm run start"
6
6
  }
7
7
 
@@ -3,11 +3,11 @@
3
3
  "version": "0.0.1",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
- "test": "npx knex migrate:rollback && npx knex migrate:up && jest",
6
+ "test": "npx dbos rollback && npx dbos migrate && jest",
7
7
  "lint": "eslint src",
8
8
  "lint-fix": "eslint --fix src",
9
9
  "dev": "nodemon",
10
- "start": "npx dbos-sdk start"
10
+ "start": "npx dbos start"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@dbos-inc/eslint-plugin": "^0.0.6",
@@ -0,0 +1,4 @@
1
+ dist
2
+ *.test.ts
3
+ jest.config.js
4
+
@@ -0,0 +1,19 @@
1
+ {
2
+ "root": true,
3
+ "extends": [
4
+ "plugin:@dbos-inc/dbosRecommendedConfig"
5
+ ],
6
+ "plugins": [
7
+ "@dbos-inc"
8
+ ],
9
+ "env": {
10
+ "node": true,
11
+ "es6": true
12
+ },
13
+ "rules": {
14
+ },
15
+ "parser": "@typescript-eslint/parser",
16
+ "parserOptions": {
17
+ "project": "./tsconfig.json"
18
+ }
19
+ }
@@ -0,0 +1,49 @@
1
+ # DBOS Hello with TypeORM
2
+
3
+ This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/dbos-sdk init` and using [TypeORM](https://docs.dbos.dev/tutorials/using-typeorm).
4
+
5
+ ## Getting Started
6
+
7
+ Before you can launch your app, you need a database.
8
+ DBOS works with any Postgres database, but to make things easier, we've provided a script that starts a Docker Postgres container and creates a database.
9
+ Run:
10
+
11
+ ```bash
12
+ node start_postgres_docker.js
13
+ ```
14
+
15
+ If successful, the script should print `Database started successfully!`.
16
+
17
+ Next, build the app:
18
+
19
+ ```bash
20
+ npm run build
21
+ ```
22
+
23
+ Then, run a schema migration to create some tables:
24
+
25
+ ```bash
26
+ npx dbos-sdk migrate
27
+ ```
28
+
29
+ If successful, the migration should print `Migration successful!`.
30
+
31
+ Finally, run the app:
32
+
33
+ ```bash
34
+ npx dbos-sdk start
35
+ ```
36
+
37
+ To see that it's working, visit this URL in your browser: [`http://localhost:3000/greeting/dbos`](http://localhost:3000/greeting/dbos).
38
+ You should get this message: `Hello, dbos! You have been greeted 1 times.`
39
+ Each time you refresh the page, the counter should go up by one!
40
+
41
+ Congratulations! You just launched a DBOS application.
42
+
43
+ ## Next Steps
44
+
45
+ - For more information on using TypeORM with DBOS, check out [our docs](https://docs.dbos.dev/tutorials/using-typeorm).
46
+ - 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`.
47
+ - For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/getting-started/quickstart-programming).
48
+ - To learn how to deploy your application to DBOS Cloud, visit our [cloud quickstart](https://docs.dbos.dev/getting-started/quickstart-cloud/)
49
+ - To learn more about DBOS, take a look at [our documentation](https://docs.dbos.dev/) or our [source code](https://github.com/dbos-inc/dbos-transact).
@@ -0,0 +1,27 @@
1
+ import { parseConfigFile } from '@dbos-inc/dbos-sdk/dist/src/dbos-runtime/config';
2
+ import { TlsOptions } from 'tls';
3
+ import { DataSource } from "typeorm";
4
+
5
+ const [dbosConfig, ] = parseConfigFile();
6
+
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'],
17
+ });
18
+
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
+ });
26
+
27
+ export default AppDataSource;
@@ -0,0 +1,20 @@
1
+ # To enable auto-completion and validation for this file in VSCode, install the RedHat YAML extension
2
+ # https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml
3
+
4
+ # yaml-language-server: $schema=https://raw.githubusercontent.com/dbos-inc/dbos-transact/main/dbos-config.schema.json
5
+
6
+ database:
7
+ hostname: 'localhost'
8
+ port: 5432
9
+ username: 'postgres'
10
+ app_db_name: 'hello_typeorm'
11
+ password: ${PGPASSWORD}
12
+ connectionTimeoutMillis: 3000
13
+ app_db_client: typeorm
14
+ migrate:
15
+ - npx typeorm migration:run -d dist/datasource.js
16
+ rollback:
17
+ - npx typeorm migration:revert -d dist/datasource.js
18
+ runtimeConfig:
19
+ entrypoints:
20
+ - dist/src/operations.js
@@ -0,0 +1,10 @@
1
+ import { Entity, PrimaryGeneratedColumn, Column } from "typeorm";
2
+
3
+ @Entity()
4
+ export class DBOSHello {
5
+ @PrimaryGeneratedColumn()
6
+ greeting_id: number = 0;
7
+
8
+ @Column()
9
+ greeting: string = "greeting";
10
+ }
@@ -0,0 +1,144 @@
1
+ # DBOS-specific
2
+ .dbos
3
+
4
+ # Logs
5
+ **/.DS_Store
6
+ **/prisma/migrations/*
7
+
8
+ logs
9
+ *.log
10
+ npm-debug.log*
11
+ yarn-debug.log*
12
+ yarn-error.log*
13
+ lerna-debug.log*
14
+ .pnpm-debug.log*
15
+ dbos_deploy/
16
+
17
+ # Diagnostic reports (https://nodejs.org/api/report.html)
18
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
19
+
20
+ # Runtime data
21
+ pids
22
+ *.pid
23
+ *.seed
24
+ *.pid.lock
25
+
26
+ # Directory for instrumented libs generated by jscoverage/JSCover
27
+ lib-cov
28
+
29
+ # Coverage directory used by tools like istanbul
30
+ coverage
31
+ *.lcov
32
+
33
+ # nyc test coverage
34
+ .nyc_output
35
+
36
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
37
+ .grunt
38
+
39
+ # Bower dependency directory (https://bower.io/)
40
+ bower_components
41
+
42
+ # node-waf configuration
43
+ .lock-wscript
44
+
45
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
46
+ build/Release
47
+
48
+ # Dependency directories
49
+ node_modules/
50
+ jspm_packages/
51
+
52
+ # Snowpack dependency directory (https://snowpack.dev/)
53
+ web_modules/
54
+
55
+ # TypeScript cache
56
+ *.tsbuildinfo
57
+
58
+ # Optional npm cache directory
59
+ .npm
60
+
61
+ # Optional eslint cache
62
+ .eslintcache
63
+
64
+ # Optional stylelint cache
65
+ .stylelintcache
66
+
67
+ # Microbundle cache
68
+ .rpt2_cache/
69
+ .rts2_cache_cjs/
70
+ .rts2_cache_es/
71
+ .rts2_cache_umd/
72
+
73
+ # Optional REPL history
74
+ .node_repl_history
75
+
76
+ # Output of 'npm pack'
77
+ *.tgz
78
+
79
+ # Yarn Integrity file
80
+ .yarn-integrity
81
+
82
+ # dotenv environment variable files
83
+ .env
84
+ .env.development.local
85
+ .env.test.local
86
+ .env.production.local
87
+ .env.local
88
+
89
+ # parcel-bundler cache (https://parceljs.org/)
90
+ .cache
91
+ .parcel-cache
92
+
93
+ # Next.js build output
94
+ .next
95
+ out
96
+
97
+ # Nuxt.js build / generate output
98
+ .nuxt
99
+ dist
100
+
101
+ # Gatsby files
102
+ .cache/
103
+ # Comment in the public line in if your project uses Gatsby and not Next.js
104
+ # https://nextjs.org/blog/next-9-1#public-directory-support
105
+ # public
106
+
107
+ # vuepress build output
108
+ .vuepress/dist
109
+
110
+ # vuepress v2.x temp and cache directory
111
+ .temp
112
+ .cache
113
+
114
+ # Docusaurus cache and generated files
115
+ .docusaurus
116
+
117
+ # Serverless directories
118
+ .serverless/
119
+
120
+ # FuseBox cache
121
+ .fusebox/
122
+
123
+ # DynamoDB Local files
124
+ .dynamodb/
125
+
126
+ # TernJS port file
127
+ .tern-port
128
+
129
+ # Stores VSCode versions used for testing VSCode extensions
130
+ .vscode-test
131
+
132
+ # VSCode settings
133
+ .vscode/settings.json
134
+
135
+ # yarn v2
136
+ .yarn/cache
137
+ .yarn/unplugged
138
+ .yarn/build-state.yml
139
+ .yarn/install-state.gz
140
+ .pnp.*
141
+
142
+ # Editor temp/recovery files
143
+ *.swp
144
+ *.swo
@@ -0,0 +1,8 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: 'ts-jest',
4
+ testEnvironment: 'node',
5
+ testRegex: '((\\.|/)(test|spec))\\.ts?$',
6
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
7
+ modulePaths: ["./"],
8
+ };
@@ -0,0 +1,14 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class DBOSHello1714934318136 implements MigrationInterface {
4
+ name = 'DBOSHello1714934318136';
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(`CREATE TABLE "dbos_hello" ("greeting_id" SERIAL NOT NULL, "greeting" character varying NOT NULL, CONSTRAINT "PK_12681863ff5f1fd5ea35f185b51" PRIMARY KEY ("greeting_id"))`);
8
+ }
9
+
10
+ public async down(queryRunner: QueryRunner): Promise<void> {
11
+ await queryRunner.query(`DROP TABLE "dbos_hello"`);
12
+ }
13
+
14
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "watch": ["src/", "migrations/", "entities/"],
3
+ "ext": "ts,json",
4
+ "ignore": ["src/**/*.test.ts"],
5
+ "exec": "npm run build && npx dbos migrate && npm run start"
6
+ }
7
+
8
+