Skip to content

Commit

Permalink
feat(@artusx/plugin-grpc): add grpc support
Browse files Browse the repository at this point in the history
  • Loading branch information
thonatos committed Mar 26, 2024
1 parent 2f0b176 commit bac552c
Show file tree
Hide file tree
Showing 41 changed files with 1,033 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Ecosystem based on Artus.js - [https://www.artusjs.org](https://www.artusjs.org)
| @artusx/plugin-log4js | [![NPM version](https://img.shields.io/npm/v/@artusx/plugin-log4js.svg?style=flat-square)](https://npmjs.org/package/@artusx/plugin-log4js) |
| @artusx/plugin-nunjucks | [![NPM version](https://img.shields.io/npm/v/@artusx/plugin-nunjucks.svg?style=flat-square)](https://npmjs.org/package/@artusx/plugin-nunjucks) |
| @artusx/plugin-schedule | [![NPM version](https://img.shields.io/npm/v/@artusx/plugin-schedule.svg?style=flat-square)](https://npmjs.org/package/@artusx/plugin-schedule) |
| @artusx/plugin-grpc | [![NPM version](https://img.shields.io/npm/v/@artusx/plugin-grpc.svg?style=flat-square)](https://npmjs.org/package/@artusx/plugin-grpc) |
| @artusx/plugin-pptr | [![NPM version](https://img.shields.io/npm/v/@artusx/plugin-pptr.svg?style=flat-square)](https://npmjs.org/package/@artusx/plugin-pptr) |
| @artusx/plugin-proxy | [![NPM version](https://img.shields.io/npm/v/@artusx/plugin-proxy.svg?style=flat-square)](https://npmjs.org/package/@artusx/plugin-proxy) |
| @artusx/plugin-openai | [![NPM version](https://img.shields.io/npm/v/@artusx/plugin-openai.svg?style=flat-square)](https://npmjs.org/package/@artusx/plugin-openai) |
Expand Down
219 changes: 219 additions & 0 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/apps/artusx-grpc/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
lib
dist
coverage
6 changes: 6 additions & 0 deletions packages/apps/artusx-grpc/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["@artusx/eslint-config"],
"parserOptions": {
"project": "./tsconfig.json"
}
}
1 change: 1 addition & 0 deletions packages/apps/artusx-grpc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
3 changes: 3 additions & 0 deletions packages/apps/artusx-grpc/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
registry=https://registry.npmjs.org/
always-auth=false
strict-ssl=false
1 change: 1 addition & 0 deletions packages/apps/artusx-grpc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# artusx-grpc
38 changes: 38 additions & 0 deletions packages/apps/artusx-grpc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "artusx-grpc",
"version": "0.0.0-dev.0",
"description": "grpc app powered by artusx",
"keywords": [
"artusx"
],
"author": "Suyi <[email protected]>",
"main": "dist/index.js",
"scripts": {
"_build": "npm run tsc",
"build": "",
"ci": "npm run lint",
"dev": "ARTUS_SERVER_ENV=development npx nodemon src/index.ts",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"start": "ARTUS_SERVER_ENV=production node dist/index.js",
"tsc": "rm -rf dist && tsc"
},
"dependencies": {
"@artus/core": "~2.2.3",
"@artusx/plugin-grpc": "workspace:*",
"@artusx/utils": "workspace:*",
"reflect-metadata": "^0.1.13",
"tslib": "^2.5.0"
},
"devDependencies": {
"@artusx/eslint-config": "workspace:*",
"@artusx/tsconfig": "workspace:*",
"@types/node": "^18.11.17",
"@typescript-eslint/eslint-plugin": "~6.19.1",
"eslint": "~8.56.0",
"eslint-plugin-import": "~2.29.1",
"nodemon": "~3.0.2",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
}
}
11 changes: 11 additions & 0 deletions packages/apps/artusx-grpc/src/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import path from 'path';
import { Application } from '@artusx/utils';

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

return app;
};
18 changes: 18 additions & 0 deletions packages/apps/artusx-grpc/src/config/config.default.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import path from 'path';

export default () => {
const grpc = {
protoList: [
path.resolve(__dirname, '../protos/helloworld.proto'),
path.resolve(__dirname, '../protos/echo.proto'),
],
server: {
host: '0.0.0.0',
port: '50051',
},
};

return {
grpc,
};
};
1 change: 1 addition & 0 deletions packages/apps/artusx-grpc/src/config/config.development.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
1 change: 1 addition & 0 deletions packages/apps/artusx-grpc/src/config/config.production.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
6 changes: 6 additions & 0 deletions packages/apps/artusx-grpc/src/config/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
grpc: {
enable: true,
package: '@artusx/plugin-grpc',
},
};
3 changes: 3 additions & 0 deletions packages/apps/artusx-grpc/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { main } from './bootstrap';

main();
Loading

0 comments on commit bac552c

Please sign in to comment.