Skip to content

Commit 313a0ce

Browse files
committed
add installation and usage instructions for each client
1 parent 693c05b commit 313a0ce

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

clients/express/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# appguard-express
2+
3+
[AppGuard](https://github.com/NullNet-ai/appguard-server) client for [Express](https://expressjs.com).
4+
5+
### Installation
6+
7+
Add the following to your `package.json`:
8+
9+
```json
10+
"dependencies": {
11+
"@nullnet/appguard-express": "^0.1.0"
12+
}
13+
```
14+
15+
### Usage
16+
17+
```typescript
18+
import express from 'express'
19+
import {createAppGuardMiddleware} from '@nullnet/appguard-express'
20+
21+
const app = express()
22+
23+
const appGuardMiddleware = createAppGuardMiddleware()
24+
25+
app.get('/some-route', appGuardMiddleware, async (req, res) => {
26+
res.json({message: 'Hello World'})
27+
})
28+
29+
app.get('*' , appGuardMiddleware, async (req, res) => {
30+
res.json({message: 'Hello World'})
31+
})
32+
33+
app.listen(3000, () => {
34+
console.log('Server is running on port 3000')
35+
})
36+
```
37+
38+
A complete working example can be found [here](https://github.com/NullNet-ai/appguard-javascript-clients/blob/main/clients/express/sample/src/index.ts).
39+
40+
### Environment variables
41+
42+
The following environment variables must be set for the client to work:
43+
- `CONTROL_SERVICE_ADDR`: AppGuard server's IP address
44+
- `CONTROL_SERVICE_PORT`: AppGuard server's port
45+
- `INSTALLATION_CODE`: installation code for this client

clients/nextjs/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# appguard-nextjs
2+
3+
[AppGuard](https://github.com/NullNet-ai/appguard-server) client for [Next.js](https://nextjs.org).
4+
5+
### Installation
6+
7+
Add the following to your `package.json`:
8+
9+
```json
10+
"dependencies": {
11+
"@nullnet/appguard-nextjs": "^0.1.0",
12+
"next": "^15.4.0-canary.67"
13+
}
14+
```
15+
16+
Be aware that a canary version of Next.js is required to use the AppGuard middleware.
17+
18+
### Usage
19+
20+
In your `middleware.ts` file, you can use the AppGuard middleware as follows:
21+
22+
```typescript
23+
import type {NextRequest} from 'next/server'
24+
import {createAppGuardMiddleware} from "../../src";
25+
26+
let appGuardMiddleware = await createAppGuardMiddleware();
27+
28+
export default async function middleware(request: NextRequest) {
29+
return await appGuardMiddleware(request);
30+
}
31+
32+
export const config = {
33+
// allow Node.js runtime for middleware: https://nextjs.org/blog/next-15-2#nodejs-middleware-experimental
34+
// this also requires next@canary: https://nextjs.org/docs/messages/ppr-preview
35+
runtime: 'nodejs',
36+
};
37+
```
38+
39+
A complete working example can be found [here](https://github.com/NullNet-ai/appguard-javascript-clients/blob/main/clients/nextjs/sample/src/middleware.ts).
40+
41+
### Environment variables
42+
43+
The following environment variables must be set for the client to work:
44+
- `CONTROL_SERVICE_ADDR`: AppGuard server's IP address
45+
- `CONTROL_SERVICE_PORT`: AppGuard server's port
46+
- `INSTALLATION_CODE`: installation code for this client

0 commit comments

Comments
 (0)