Skip to content

Commit 447afb5

Browse files
PanovYurylitongjava
authored andcommitted
update deno and oak versions and using postgresjs (TechEmpower#9877)
Co-authored-by: = <=>
1 parent 7be1ad6 commit 447afb5

File tree

15 files changed

+559
-128
lines changed

15 files changed

+559
-128
lines changed

frameworks/TypeScript/oak/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
### Test Type Implementation Source Code
44

5-
- [PLAINTEXT](src/routes.ts#L15)
6-
- [JSON](src/routes.ts#L16)
7-
- [DB](src/routes.ts#L17)
8-
- [QUERY](src/routes.ts#L24)
9-
- [UPDATE](src/routes.ts#L37)
10-
- [FORTUNES](src/routes.ts#L53)
11-
- [CACHED QUERY](src/routes.ts#L67)
5+
- [PLAINTEXT](src/routes.ts#L18)
6+
- [JSON](src/routes.ts#L19)
7+
- [DB](src/routes.ts#L25)
8+
- [QUERY](src/routes.ts#L29)
9+
- [UPDATE](src/routes.ts#L39)
10+
- [FORTUNES](src/routes.ts#L59)
11+
- [CACHED QUERY](src/routes.ts#L73)
1212

1313
## Important Libraries
1414

1515
The tests were run with:
1616

1717
- [deno](https://deno.land)
1818
- [oak](https://deno.land/x/oak/)
19-
- [cotton](https://deno.land/x/cotton/)
19+
- [Postgres.js](https://github.com/porsager/postgres/)
2020

2121
## Test URLs
2222

@@ -34,16 +34,16 @@ http://localhost:8080/db
3434

3535
### QUERY
3636

37-
http://localhost:8080/query?q=
37+
http://localhost:8080/queries?q=
3838

3939
### UPDATE
4040

41-
http://localhost:8080/update?q=
41+
http://localhost:8080/updates?q=
4242

4343
### FORTUNES
4444

4545
http://localhost:8080/fortunes
4646

4747
### CACHED QUERY
4848

49-
http://localhost:8080/cached_query?q=
49+
http://localhost:8080/cached_queries?q=

frameworks/TypeScript/oak/benchmark_config.json

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33
"tests": [
44
{
55
"default": {
6+
"json_url": "/json",
7+
"plaintext_url": "/plaintext",
8+
"port": 8080,
9+
"approach": "Realistic",
10+
"classification": "Micro",
11+
"database": "None",
12+
"framework": "oak",
13+
"language": "TypeScript",
14+
"flavor": "deno",
15+
"orm": "None",
16+
"platform": "deno",
17+
"webserver": "None",
18+
"os": "Linux",
19+
"database_os": "Linux",
20+
"display_name": "oak",
21+
"notes": "",
22+
"versus": "nodejs"
23+
}
24+
},
25+
{
26+
"postgresjs": {
627
"json_url": "/json",
728
"plaintext_url": "/plaintext",
829
"db_url": "/db",
@@ -12,20 +33,19 @@
1233
"cached_query_url": "/cached_queries?q=",
1334
"port": 8080,
1435
"approach": "Realistic",
15-
"classification": "Platform",
36+
"classification": "Micro",
1637
"database": "postgres",
17-
"framework": "None",
18-
"language": "Typescript",
38+
"database_os": "Linux",
39+
"framework": "oak",
40+
"language": "TypeScript",
1941
"flavor": "deno",
20-
"orm": "Micro",
42+
"orm": "Raw",
2143
"platform": "deno",
2244
"webserver": "None",
2345
"os": "Linux",
24-
"database_os": "Linux",
25-
"display_name": "oak",
46+
"display_name": "oak [postgresjs]",
2647
"notes": "",
27-
"versus": "nodejs",
28-
"tags": ["broken"]
48+
"versus": "nodejs"
2949
}
3050
}
3151
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"imports": {
3+
"oak": "jsr:@oak/[email protected]",
4+
"postgres": "https://deno.land/x/[email protected]/mod.js",
5+
"lru-cache": "jsr:@std/[email protected]/lru-cache",
6+
"html": "https://deno.land/x/[email protected]/mod.ts"
7+
}
8+
}

frameworks/TypeScript/oak/deno.lock

Lines changed: 391 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM denoland/deno:2.3.1
2+
3+
EXPOSE 8080
4+
5+
WORKDIR /app
6+
7+
USER deno
8+
9+
ENV PG_NAME hello_world
10+
ENV PG_HOST tfb-database
11+
ENV PG_USER benchmarkdbuser
12+
ENV PG_PSWD benchmarkdbpass
13+
ENV DATABASE postgres
14+
15+
COPY . .
16+
17+
RUN deno install --entrypoint ./src/main.ts
18+
19+
CMD ["deno", "serve", "--parallel", "--port", "8080", "--host", "0.0.0.0", "-A", "./src/main.ts"]
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
FROM denoland/deno
1+
FROM denoland/deno:2.3.1
22

33
EXPOSE 8080
44

55
WORKDIR /app
66

77
USER deno
88

9-
COPY ./src/deps.ts .
10-
RUN deno cache deps.ts
11-
ADD ./src .
12-
CMD [ "run", "--allow-all", "main.ts" ]
9+
COPY . .
10+
11+
RUN deno install --entrypoint ./src/main.ts
12+
13+
CMD ["deno", "serve", "--parallel", "--port", "8080", "--host", "0.0.0.0", "-A", "./src/main.ts"]

frameworks/TypeScript/oak/src/deps.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

frameworks/TypeScript/oak/src/helpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Context, ResponseBody, Status } from "./deps.ts";
1+
import { Context, Status } from "oak";
2+
import { ResponseBody } from "oak/response";
23

34
export function Ok(ctx: Context, body: ResponseBody) {
45
ctx.response.status = Status.OK;
Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import { Application, DatabaseResult, Manager } from "./deps.ts";
1+
import { Application } from "oak";
22
import { router } from "./routes.ts";
3-
import { getDbClient } from "./utils.ts";
43

5-
const app = new Application<
6-
{ manager: Manager; cached_worlds: DatabaseResult[] }
7-
>();
4+
const app = new Application();
85

96
// headers
107
app.use(async (ctx, next) => {
@@ -13,15 +10,7 @@ app.use(async (ctx, next) => {
1310
await next();
1411
});
1512

16-
// database handling
17-
app.use(async (ctx, next) => {
18-
const db = await getDbClient();
19-
ctx.state.manager = db.getManager();
20-
await next();
21-
await db.disconnect();
22-
});
23-
2413
app.use(router.routes());
2514
app.use(router.allowedMethods());
2615

27-
await app.listen({ port: 8080 });
16+
export default { fetch: app.fetch };

frameworks/TypeScript/oak/src/models.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)