Skip to content

Commit

Permalink
Merge pull request #9500 from KostyaTretyak/master
Browse files Browse the repository at this point in the history
chore(TypeScript/ditsmod): upgrade and fix version of some deps
  • Loading branch information
msmith-techempower authored Jan 9, 2025
2 parents 09963cc + f5660e3 commit fc4e693
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
10 changes: 5 additions & 5 deletions frameworks/TypeScript/ditsmod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"author": "Костя Третяк",
"license": "MIT",
"dependencies": {
"@ditsmod/core": "^3.0.0-alpha.2",
"@ditsmod/routing": "^3.0.0-alpha.2",
"@ditsmod/core": "3.0.0-alpha.3",
"@ditsmod/routing": "3.0.0-alpha.3",
"handlebars": "^4.7.8",
"lru-cache": "^11.0.0",
"mariadb": "^3.3.1",
"postgres": "^3.4.4"
"lru-cache": "^11.0.2",
"mariadb": "^3.4.0",
"postgres": "^3.4.5"
},
"devDependencies": {
"@types/eslint": "^8.44.2",
Expand Down
5 changes: 2 additions & 3 deletions frameworks/TypeScript/ditsmod/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Providers, rootModule } from '@ditsmod/core';
import { InjectionToken, Providers, rootModule } from '@ditsmod/core';
import { PRE_ROUTER_EXTENSIONS, RoutingModule } from '@ditsmod/routing';

import { OneController } from './one.controller.js';
import { InitExtension } from './init.extension.js';
import { DB_INIT_EXTENSIONS } from './tokens.js';

@rootModule({
imports: [RoutingModule],
providersPerApp: new Providers().useLogConfig({ level: 'off' }),
extensions: [{ extension: InitExtension, group: DB_INIT_EXTENSIONS, beforeGroup: PRE_ROUTER_EXTENSIONS }],
extensions: [{ extension: InitExtension, group: new InjectionToken('test'), beforeGroups: [PRE_ROUTER_EXTENSIONS] }],
controllers: [OneController],
})
export class AppModule {}
18 changes: 10 additions & 8 deletions frameworks/TypeScript/ditsmod/src/app/one.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnyObj, controller, RequestContext, SingletonRequestContext, optional } from '@ditsmod/core';
import { AnyObj, controller, RequestContext, optional } from '@ditsmod/core';
import { route } from '@ditsmod/routing';
import Handlebars from 'handlebars';

Expand Down Expand Up @@ -28,7 +28,7 @@ const tmpl = Handlebars.compile(
].join(''),
);

@controller({ scope: 'module' })
@controller({ scope: 'ctx' })
export class OneController {
constructor(@optional() private dbService: DbService) {}

Expand All @@ -40,19 +40,19 @@ export class OneController {
}

@route('GET', 'queries')
async getMultiQueries(ctx: SingletonRequestContext) {
async getMultiQueries(ctx: RequestContext) {
const result = await this.dbService.getMultiQueries(ctx.queryParams!.queries);
this.sendJson(ctx, result);
}

@route('GET', 'cached-queries')
async getCachedWorlds(ctx: SingletonRequestContext) {
async getCachedWorlds(ctx: RequestContext) {
const result = await this.dbService.getMultiQueries(ctx.queryParams!.count, false);
this.sendJson(ctx, result);
}

@route('GET', 'updates')
async getUpdates(ctx: SingletonRequestContext) {
async getUpdates(ctx: RequestContext) {
const worlds = await this.dbService.saveWorlds(ctx.queryParams!.queries);
this.sendJson(ctx, worlds);
}
Expand All @@ -68,18 +68,20 @@ export class OneController {
}

@route('GET', 'plaintext')
getHello(ctx: SingletonRequestContext) {
getHello(ctx: RequestContext) {
ctx.rawRes.setHeader('Server', 'Ditsmod');
ctx.rawRes.setHeader('Content-Type', 'text/plain; charset=utf-8');
ctx.rawRes.end('Hello, World!');
}

@route('GET', 'json')
getJson(ctx: SingletonRequestContext) {
getJson(ctx: RequestContext) {
this.sendJson(ctx, { message: 'Hello, World!' });
}

protected sendJson(ctx: RequestContext, value: AnyObj) {
ctx.setHeader('Server', 'Ditsmod').sendJson(value);
ctx.rawRes.setHeader('Server', 'Ditsmod');
ctx.rawRes.setHeader('Content-Type', 'application/json; charset=utf-8');
ctx.rawRes.end(JSON.stringify(value));
}
}
6 changes: 0 additions & 6 deletions frameworks/TypeScript/ditsmod/src/app/tokens.ts

This file was deleted.

0 comments on commit fc4e693

Please sign in to comment.