Skip to content

Commit 48d42f3

Browse files
authored
Merge pull request #27 from AmRo045/dev
Improve the dak endpoint & update instructions
2 parents de3cbed + ab8b79d commit 48d42f3

File tree

4 files changed

+44
-14
lines changed

4 files changed

+44
-14
lines changed

README.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ Outline Admin is a web interface for the Outline Manager API, providing a simple
1616
- [Docker](#docker)
1717
- [Docker Compose](#docker-compose)
1818
- [NodeJS](#nodejs)
19-
3. [Development](#development)
20-
4. [Admin Password](#admin-password)
21-
5. [Donation](#donation)
22-
6. [Screenshots](#screenshots)
19+
3. [Updating to Latest Version](#updating-to-latest-version)
20+
4. [Development](#development)
21+
5. [Admin Password](#admin-password)
22+
6. [Donation](#donation)
23+
7. [Screenshots](#screenshots)
2324

2425
## Added Features
2526

@@ -28,7 +29,6 @@ Outline Admin is a web interface for the Outline Manager API, providing a simple
2829
- Dynamic Access Keys.
2930
- Access Key prefix.
3031

31-
3232
## Installation
3333

3434
### Docker
@@ -93,6 +93,33 @@ cd .next/standalone
9393
node server.js
9494
```
9595

96+
## Updating to Latest Version
97+
98+
Pull the latest version of the outline-admin image
99+
```bash
100+
docker pull amro045/outline-admin:latest
101+
```
102+
103+
Stop running container
104+
105+
```bash
106+
docker compose down
107+
```
108+
109+
Restart the container
110+
111+
```bash
112+
docker compose up -d
113+
```
114+
115+
Clean up the old image to free up disk space
116+
117+
```bash
118+
docker rmi {old-image-id}
119+
```
120+
121+
Replace {old-image-id} with the ID of the old image you want to remove.
122+
96123
## Development
97124

98125
Follow the steps below:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "outline-admin",
3-
"version": "0.1.15",
3+
"version": "0.1.17",
44
"private": true,
55
"scripts": {
66
"compile": "tsc -p tsconfig.scripts.json && tscpaths -p tsconfig.scripts.tscpaths.json -s ./dist -o ./dist",

src/app/api/dak/[...path]/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface ContextProps {
2020
export async function GET(req: Request, context: ContextProps) {
2121
const path = context.params.path.join("/");
2222

23-
const dynamicAccessKey = await getDynamicAccessKeyByPath(path, true);
23+
const dynamicAccessKey = await getDynamicAccessKeyByPath(path);
2424

2525
if (!dynamicAccessKey) {
2626
return NextResponse.json({
@@ -84,7 +84,7 @@ const selectAccessKey = async (
8484

8585
switch (dynamicAccessKey.loadBalancerAlgorithm) {
8686
case LoadBalancerAlgorithm.UserIpAddress:
87-
return selectedAccessKeyByClientIp(accessKeys, clientIp);
87+
return selectAccessKeyByClientIp(accessKeys, clientIp);
8888

8989
case LoadBalancerAlgorithm.RandomServerKeyOnEachConnection:
9090
return selectRandomServerKey(accessKeys);
@@ -95,7 +95,7 @@ const selectAccessKey = async (
9595
}
9696
};
9797

98-
const selectedAccessKeyByClientIp = (accessKeys: AccessKey[], clientIp: string) => {
98+
const selectAccessKeyByClientIp = (accessKeys: AccessKey[], clientIp: string) => {
9999
const hash = crc32(clientIp);
100100
const index = hash % accessKeys.length;
101101

src/core/actions/dynamic-access-key.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,19 @@ export async function getDynamicAccessKeyById(
5555
});
5656
}
5757

58-
export async function getDynamicAccessKeyByPath(
59-
path: string,
60-
withKeys: boolean = false
61-
): Promise<DynamicAccessKeyWithAccessKeys | null> {
58+
export async function getDynamicAccessKeyByPath(path: string): Promise<DynamicAccessKeyWithAccessKeys | null> {
6259
return prisma.dynamicAccessKey.findFirst({
6360
where: {
6461
path
6562
},
6663
include: {
67-
accessKeys: withKeys
64+
accessKeys: {
65+
where: {
66+
server: {
67+
isAvailable: true
68+
}
69+
}
70+
}
6871
}
6972
});
7073
}

0 commit comments

Comments
 (0)