Skip to content

Commit

Permalink
feat: add webapp artusx-web
Browse files Browse the repository at this point in the history
  • Loading branch information
thonatos committed Jan 3, 2024
1 parent b1ca87f commit 7759aa3
Show file tree
Hide file tree
Showing 13 changed files with 364 additions and 4 deletions.
273 changes: 273 additions & 0 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions packages/apps/artusx-web/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "artusx-web",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "npx nodemon src/bootstrap.ts",
"build": ""
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"nodemon": "~3.0.2",
"@artus/core": "~2.2.0",
"@artusx/core": "workspace:*",
"@artusx/run": "workspace:*",
"@artusx/plugin-application-http": "workspace:*",
"tslib": "~2.6.2",
"typescript": "~5.3.3"
},
"devDependencies": {
"nodemon": "~3.0.2",
"ts-node": "~10.9.2",
"@types/node": "~20.10.6",
"@artus/tsconfig": "~1.0.1"
}
}
12 changes: 12 additions & 0 deletions packages/apps/artusx-web/src/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import path from 'path';
import { Application } from '@artusx/run';

(async () => {
const app = await Application.start({
root: path.resolve(__dirname),
name: 'app',
configDir: 'config'
});

console.log(app.config);
})();
5 changes: 5 additions & 0 deletions packages/apps/artusx-web/src/config/config.default.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
framework: {
package: '@artusx/core'
}
};
8 changes: 8 additions & 0 deletions packages/apps/artusx-web/src/config/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
redis: {
enable: false
},
sequelize: {
enable: false
}
};
11 changes: 11 additions & 0 deletions packages/apps/artusx-web/src/controller/home.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { GET, HTTPController } from '@artusx/plugin-application-http';

import { HTTPContext } from '@artusx/plugin-application-http';

@HTTPController()
export default class HomeController {
@GET('/')
async home(ctx: HTTPContext) {
ctx.body = 'Hello World';
}
}
11 changes: 11 additions & 0 deletions packages/apps/artusx-web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "@artus/tsconfig",
"compilerOptions": {
"baseUrl": ".",
"strictNullChecks": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"outDir": "dist"
},
"include": ["src/**/*.ts", "src/**/*.json"]
}
2 changes: 1 addition & 1 deletion packages/libs/application/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@artusx/run",
"version": "1.0.1-dev.11",
"description": "core application for artusx",
"main": "dist/Application.js",
"main": "dist/application.js",
"files": [
"dist"
],
Expand Down
3 changes: 2 additions & 1 deletion packages/plugins/application-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "@artusx/plugin-application-http",
"version": "1.0.1-dev.11",
"description": "application-http plugin for artusx",
"main": "dist/app.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions packages/plugins/application-http/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './lifecycle';
export * from './decorator';
export * from './types';
7 changes: 5 additions & 2 deletions packages/plugins/application-http/src/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export default class ApplicationHttpLifecycle implements ApplicationLifecycle {
return this.app.container;
}

get logger() {
return this.app.logger;
}

private registerRoute(
controllerMetadata: ControllerMetadata,
routeMetadataList: RouteMetadata[],
Expand Down Expand Up @@ -121,8 +125,7 @@ export default class ApplicationHttpLifecycle implements ApplicationLifecycle {

app.use(this.router.routes());
app.listen(port, () => {
// this.logger.info(`Server listening on: http://localhost:${port}`);
console.log(`Server listening on: http://localhost:${port}`);
this.logger.info(`Server listening on: http://localhost:${port}`);
});
}
}
5 changes: 5 additions & 0 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,11 @@
"tags": ["artus-app"],
"shouldPublish": true,
"versionPolicyName": "public-library"
},
{
"packageName": "artusx-web",
"projectFolder": "packages/apps/artusx-web",
"tags": ["webapp"]
}
// {
// /**
Expand Down

0 comments on commit 7759aa3

Please sign in to comment.