@dbos-inc/create 3.0.38-preview.g8bb2030562 → 3.0.43-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.
@@ -1,58 +0,0 @@
1
- // Welcome to DBOS!
2
-
3
- // This is the Quickstart Prisma template app. It greets visitors, counting how many total greetings were made.
4
- // To learn how to run this app, visit the Prisma tutorial: https://docs.dbos.dev/tutorials/using-prisma
5
-
6
- import { DBOS } from '@dbos-inc/dbos-sdk';
7
-
8
- import { PrismaClient } from '@prisma/client';
9
-
10
- export class Hello {
11
- // Serve this function from HTTP GET requests at the /greeting endpoint with 'name' as a path parameter
12
- @DBOS.getApi('/greeting/:name')
13
- @DBOS.transaction()
14
- static async helloTransaction(name: string) {
15
- const greeting = `Hello, ${name}!`;
16
- const res = await (DBOS.prismaClient as PrismaClient).dbosHello.create({
17
- data: {
18
- greeting: greeting,
19
- },
20
- });
21
- const greeting_note = `Greeting ${res.greeting_id}: ${greeting}`;
22
- return Hello.makeHTML(greeting_note);
23
- }
24
-
25
- // Serve a quick readme for the app at the / endpoint
26
- @DBOS.getApi('/')
27
- static async readme() {
28
- const message = Hello.makeHTML(
29
- `Visit the route <code class="bg-gray-100 px-1 rounded">/greeting/{name}</code> to be greeted!<br>
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>
31
- The counter increments with each page visit.`,
32
- );
33
- return Promise.resolve(message);
34
- }
35
-
36
- // A helper function to create HTML pages with some styling
37
- static makeHTML(message: string) {
38
- const page =
39
- `
40
- <!DOCTYPE html>
41
- <html lang="en">
42
- <head>
43
- <title>DBOS Template App</title>
44
- <script src="https://cdn.tailwindcss.com"></script>
45
- </head>
46
- <body class="font-sans text-gray-800 p-6 max-w-2xl mx-auto">
47
- <h1 class="text-3xl font-semibold mb-4">Welcome to DBOS!</h1>
48
- <p class="mt-8 mb-8">` +
49
- message +
50
- `</p>
51
- <p class="mb-2">
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>.
53
- </p>
54
- </body>
55
- </html>`;
56
- return page;
57
- }
58
- }
@@ -1,56 +0,0 @@
1
- // Welcome to DBOS!
2
-
3
- // This is the Quickstart TypeORM template app. It greets visitors, counting how many total greetings were made.
4
- // To learn how to run this app, visit the TypeORM tutorial: https://docs.dbos.dev/tutorials/using-typeorm
5
-
6
- import { DBOS, OrmEntities } from '@dbos-inc/dbos-sdk';
7
- import { EntityManager } from 'typeorm';
8
- import { DBOSHello } from '../entities/DBOSHello';
9
-
10
- @OrmEntities([DBOSHello])
11
- export class Hello {
12
- @DBOS.getApi('/greeting/:name')
13
- @DBOS.transaction()
14
- static async helloTransaction(name: string) {
15
- const greeting = `Hello, ${name}!`;
16
- let entity = new DBOSHello();
17
- entity.greeting = greeting;
18
- entity = await (DBOS.typeORMClient as EntityManager).save(entity);
19
- const greeting_note = `Greeting ${entity.greeting_id}: ${greeting}`;
20
- return Hello.makeHTML(greeting_note);
21
- }
22
-
23
- // Serve a quick readme for the app at the / endpoint
24
- @DBOS.getApi('/')
25
- static async readme() {
26
- const message = Hello.makeHTML(
27
- `Visit the route <code class="bg-gray-100 px-1 rounded">/greeting/{name}</code> to be greeted!<br>
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>
29
- The counter increments with each page visit.`,
30
- );
31
- return Promise.resolve(message);
32
- }
33
-
34
- // A helper function to create HTML pages with some styling
35
- static makeHTML(message: string) {
36
- const page =
37
- `
38
- <!DOCTYPE html>
39
- <html lang="en">
40
- <head>
41
- <title>DBOS Template App</title>
42
- <script src="https://cdn.tailwindcss.com"></script>
43
- </head>
44
- <body class="font-sans text-gray-800 p-6 max-w-2xl mx-auto">
45
- <h1 class="text-3xl font-semibold mb-4">Welcome to DBOS!</h1>
46
- <p class="mt-8 mb-8">` +
47
- message +
48
- `</p>
49
- <p class="mb-2">
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>.
51
- </p>
52
- </body>
53
- </html>`;
54
- return page;
55
- }
56
- }