Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(JavaScript/ditsmod): upgrade ditsmod and added support for bun. #7960

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions javascript/ditsmod-bun/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules
dist*
*.log
13 changes: 13 additions & 0 deletions javascript/ditsmod-bun/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
framework:
github: ditsmod/ditsmod
website: ditsmod.github.io/en
version: 2.61

engines:
- bun

bootstrap:
- bun install
- bun run build

command: pm2-runtime start --interpreter ~/.bun/bin/bun dist/main.js -i max
26 changes: 26 additions & 0 deletions javascript/ditsmod-bun/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "ditsmod-bun",
"type": "module",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "bun dist/main.js",
"build": "tsc -b && rm node_modules/@ditsmod/*/tsconfig.json",
"clean": "rm -rf dist*"
},
"imports": {
"#src/*": "./dist/*"
},
"keywords": [],
"author": "Your Name Here",
"license": "MIT",
"dependencies": {
"@ditsmod/body-parser": "~2.17.1",
"@ditsmod/core": "~2.61.1",
"@ditsmod/routing": "~2.7.0"
},
"devDependencies": {
"@types/node": "^22.9.0",
"typescript": "^5.6.3"
}
}
10 changes: 10 additions & 0 deletions javascript/ditsmod-bun/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { rootModule } from '@ditsmod/core';
import { RoutingModule } from '@ditsmod/routing';
import { BodyParserModule } from '@ditsmod/body-parser';
import { HelloWorldController } from './hello-world.controller.js';

@rootModule({
imports: [RoutingModule, BodyParserModule],
controllers: [HelloWorldController],
})
export class AppModule {}
19 changes: 19 additions & 0 deletions javascript/ditsmod-bun/src/app/hello-world.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { controller, SingletonRequestContext, route } from '@ditsmod/core';

@controller({ isSingleton: true })
export class HelloWorldController {
@route('GET')
empty(ctx: SingletonRequestContext) {
ctx.nodeRes.end();
}

@route('GET', 'user/:id')
userId(ctx: SingletonRequestContext) {
ctx.nodeRes.end(ctx.pathParams!.id);
}

@route('POST', 'user')
postHello(ctx: SingletonRequestContext) {
ctx.nodeRes.end();
}
}
8 changes: 8 additions & 0 deletions javascript/ditsmod-bun/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Application } from '@ditsmod/core';
import type { ServerOptions } from 'node:http';

import { AppModule } from './app/app.module.js';

const serverOptions: ServerOptions = { keepAlive: true, keepAliveTimeout: 0 };
const app = await new Application().bootstrap(AppModule, { serverOptions });
app.server.listen(3000, '0.0.0.0');
22 changes: 22 additions & 0 deletions javascript/ditsmod-bun/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"strict": true,
"target": "es2022",
"module": "nodenext",
"moduleResolution": "nodenext",
"outDir": "dist",
"rootDir": "src",
"tsBuildInfoFile": "dist/build.tsbuildinfo",
"sourceMap": true,
"composite": true,
"declaration": true,
"declarationMap": true,
"skipLibCheck": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"strictPropertyInitialization": false
},
"include": ["src"]
}
2 changes: 1 addition & 1 deletion javascript/ditsmod/config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
framework:
github: ditsmod/ditsmod
website: ditsmod.github.io/en
version: 2.60
version: 2.61

bootstrap:
- npm install
Expand Down
10 changes: 5 additions & 5 deletions javascript/ditsmod/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "ditsmod-seed",
"name": "ditsmod-node",
"type": "module",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "npm run build && node dist/main.js",
"build": "tsc -b && rm node_modules/@ditsmod/*/tsconfig.json",
"build": "tsc -b",
"clean": "rm -rf dist*"
},
"imports": {
Expand All @@ -16,11 +16,11 @@
"license": "MIT",
"dependencies": {
"@ditsmod/body-parser": "~2.17.1",
"@ditsmod/core": "~2.61.0",
"@ditsmod/core": "~2.61.1",
"@ditsmod/routing": "~2.7.0"
},
"devDependencies": {
"@types/node": "22",
"typescript": "5.6.3"
"@types/node": "^22.9.0",
"typescript": "^5.6.3"
}
}
Loading