@dbos-inc/create 1.8.12-preview → 1.8.13-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/package.json +1 -1
- package/templates/hello/README.md +9 -12
- package/templates/hello/nodemon.json +1 -1
- package/templates/hello/package-lock.json +118 -121
- package/templates/hello/package.json +8 -8
- package/templates/hello-typeorm/.eslintignore +4 -0
- package/templates/hello-typeorm/.eslintrc +19 -0
- package/templates/hello-typeorm/README.md +51 -0
- package/templates/hello-typeorm/datasource.ts +27 -0
- package/templates/hello-typeorm/dbos-config.yaml +20 -0
- package/templates/hello-typeorm/entities/DBOSHello.ts +10 -0
- package/templates/hello-typeorm/gitignore.template +144 -0
- package/templates/hello-typeorm/jest.config.js +8 -0
- package/templates/hello-typeorm/migrations/1714934318136-DBOSHello.ts +19 -0
- package/templates/hello-typeorm/nodemon.json +8 -0
- package/templates/hello-typeorm/package-lock.json +6161 -0
- package/templates/hello-typeorm/package.json +29 -0
- package/templates/hello-typeorm/src/operations.test.ts +26 -0
- package/templates/hello-typeorm/src/operations.ts +17 -0
- package/templates/hello-typeorm/start_postgres_docker.js +40 -0
- package/templates/hello-typeorm/tsconfig.json +27 -0
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
TypeORM provides rich support for [schema migrations](https://typeorm.io/migrations), including automatic generation of migration files from entity files.
|
|
25
|
+
Fore more information, see [our docs](https://docs.dbos.dev/tutorials/using-typeorm).
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx dbos-sdk migrate
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If successful, the migration should print `Migration successful!`.
|
|
32
|
+
|
|
33
|
+
Finally, run the app:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx dbos-sdk start
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
To see that it's working, visit this URL in your browser: [`http://localhost:3000/greeting/dbos`](http://localhost:3000/greeting/dbos).
|
|
40
|
+
You should get this message: `Hello, dbos! You have been greeted 1 times.`
|
|
41
|
+
Each time you refresh the page, the counter should go up by one!
|
|
42
|
+
|
|
43
|
+
Congratulations! You just launched a DBOS application.
|
|
44
|
+
|
|
45
|
+
## Next Steps
|
|
46
|
+
|
|
47
|
+
- For more information on using TypeORM with DBOS, check out [our docs](https://docs.dbos.dev/tutorials/using-typeorm).
|
|
48
|
+
- 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`.
|
|
49
|
+
- For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/getting-started/quickstart-programming).
|
|
50
|
+
- To learn how to deploy your application to DBOS Cloud, visit our [cloud quickstart](https://docs.dbos.dev/getting-started/quickstart-cloud/)
|
|
51
|
+
- 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,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,19 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
// This migration file was automatically generated from the project entity files (entities/*.ts).
|
|
4
|
+
// This was done by running on an empty database the command: `npx typeorm migration:generate -d dist/datasource.js migrations/DBOSHello`
|
|
5
|
+
// This file creates the schema defined in the entity files.
|
|
6
|
+
// For more information on schema management with TypeORM and DBOS, see our docs: https://docs.dbos.dev/tutorials/using-typeorm
|
|
7
|
+
|
|
8
|
+
export class DBOSHello1714934318136 implements MigrationInterface {
|
|
9
|
+
name = 'DBOSHello1714934318136';
|
|
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
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|