Skip to content

Commit 15a0e07

Browse files
committed
fix grpc proto load path
1 parent b7b16cc commit 15a0e07

File tree

15 files changed

+63
-67
lines changed

15 files changed

+63
-67
lines changed

client_common/package-lock.json

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client_common/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
},
2323
"dependencies": {
2424
"@grpc/grpc-js": "^1.3.2",
25-
"@grpc/proto-loader": "^0.6.2"
25+
"@grpc/proto-loader": "^0.6.2",
26+
"dotenv": "^16.5.0"
2627
},
2728
"husky": {
2829
"hooks": {

client_common/src/appguard.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ import {TOKEN_FILE} from "./auth";
1414
import {AppGuardFirewall, AppGuardFirewall__Output} from "./proto/appguard/AppGuardFirewall";
1515
import {FirewallPolicy} from "./proto/appguard/FirewallPolicy";
1616

17-
const PROTO_FILE = process.cwd() + '/../proto/appguard.proto'
18-
const packageDef = protoLoader.loadSync(PROTO_FILE)
17+
const opts = {includeDirs: [
18+
'node_modules/@nullnet/appguard-express/node_modules/appguard-client-common/proto/',
19+
'node_modules/@nullnet/appguard-nextjs/node_modules/appguard-client-common/proto/',
20+
]};
21+
const packageDef = protoLoader.loadSync('appguard.proto', opts);
1922
const grpcObj = (grpc.loadPackageDefinition(packageDef) as unknown) as ProtoGrpcType
2023

2124
// it doesn't work with .cer files, convert them to .pem with the following command:

clients/express/package-lock.json

Lines changed: 4 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/express/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"dependencies": {
2424
"appguard-client-common": "file:../../client_common",
2525
"body-parser": "^1.20.2",
26-
"dotenv": "^16.5.0",
2726
"express": "^4.19.2",
2827
"nodemon": "^3.1.2"
2928
},
@@ -33,16 +32,16 @@
3332
"singleQuote": true,
3433
"trailingComma": "es5"
3534
},
36-
"name": "@nullnet/app-guard-express",
35+
"name": "@nullnet/appguard-express",
3736
"author": "Giuliano Bellini s294739",
38-
"module": "dist/app-guard-express.esm.js",
37+
"module": "dist/appguard-express.esm.js",
3938
"size-limit": [
4039
{
41-
"path": "dist/app-guard-express.cjs.production.min.js",
40+
"path": "dist/appguard-express.cjs.production.min.js",
4241
"limit": "10 KB"
4342
},
4443
{
45-
"path": "dist/app-guard-express.esm.js",
44+
"path": "dist/appguard-express.esm.js",
4645
"limit": "10 KB"
4746
}
4847
],

clients/express/sample/package-lock.json

Lines changed: 7 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/express/sample/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"author": "bon",
1111
"license": "AGPL-3.0-only",
1212
"dependencies": {
13-
"@nullnet/app-guard-express": "file:../",
13+
"@nullnet/appguard-express": "file:../",
1414
"express": "^4.19.2"
1515
},
1616
"devDependencies": {

clients/express/sample/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1313
};
1414
Object.defineProperty(exports, "__esModule", { value: true });
1515
const express_1 = __importDefault(require("express"));
16-
const app_guard_1 = __importDefault(require("./modules/app-guard"));
16+
const app_guard_1 = __importDefault(require("./modules/appguard"));
1717
const app = (0, express_1.default)();
1818
// AC #1:
1919
// Able to use as direct express module

clients/express/sample/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import express from 'express'
2-
import {AppGuardConfig, createAppGuardMiddleware, FirewallPolicy} from '@nullnet/app-guard-express'
2+
import {AppGuardConfig, createAppGuardMiddleware, FirewallPolicy} from '@nullnet/appguard-express'
33

44
const app = express()
55

@@ -21,16 +21,19 @@ const appGuardMiddleware = createAppGuardMiddleware(appGuardConfig)
2121

2222
// AC #2:
2323
// Able to use as middleware to specific route
24+
// @ts-ignore
2425
app.get('/some-route', appGuardMiddleware, async (req, res) => {
2526
res.json({message: 'Hello World'})
2627
})
2728

29+
// @ts-ignore
2830
app.get('/index' , appGuardMiddleware, async (req, res) => {
2931
res.json({message: 'Hello World'})
3032
})
3133

3234
// AC #3:
3335
// Able to uses a default route controller
36+
// @ts-ignore
3437
app.get('*' , appGuardMiddleware, async (req, res) => {
3538
res.json({message: 'Hello World'})
3639
})

clients/express/src/express-middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export const createAppGuardMiddleware = (config: AppGuardConfig) => {
142142
console.error(error);
143143
// @ts-ignore
144144
res.status(500).send({
145-
module: 'app-guard',
145+
module: 'appguard',
146146
message: 'Internal server error',
147147
});
148148
}

0 commit comments

Comments
 (0)