Skip to content

Commit 6df9b38

Browse files
authored
Merge pull request #175 from import-ai/feature/application
Feature/application
2 parents 9618920 + ad1f83c commit 6df9b38

32 files changed

+1264
-36
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ jobs:
179179
run: |
180180
curl "${{ secrets.DEV_WEBHOOK_URL }}/dev" -H "Authorization: Bearer ${{ secrets.DEV_WEBHOOK_API_KEY }}"
181181
182-
- name: PR Webhook
182+
- name: TEST Webhook
183183
if: github.event_name == 'pull_request'
184184
run: |
185-
curl "${{ secrets.DEV_WEBHOOK_URL }}/pr?module=backend&pr=pr-${{ github.event.number }}" -H "Authorization: Bearer ${{ secrets.DEV_WEBHOOK_API_KEY }}"
185+
curl "${{ secrets.DEV_WEBHOOK_URL }}/test?module=backend&pr=pr-${{ github.event.number }}&commit=${{ github.event.pull_request.head.sha }}" -H "Authorization: Bearer ${{ secrets.DEV_WEBHOOK_API_KEY }}"
186186
187187
- name: PROD Webhook
188188
if: false && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')

helm/backend/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

helm/backend/Chart.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v2
2+
name: OmniBox Backend
3+
description: OmniBox Backend Service
4+
5+
type: application
6+
version: 0.1.0
7+
appVersion: "0.1.0"
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{{- $name := default .Release.Name .Values.release.name }}
2+
{{- $namespace := default .Release.Namespace .Values.release.namespace }}
3+
4+
{{- if ne $name .Release.Name }}
5+
{{ fail (printf "Name from command line not equal to config's: %s != %s" ($name | quote) (.Release.Name | quote)) }}
6+
{{- end }}
7+
8+
{{- if ne $namespace .Release.Namespace }}
9+
{{ fail (printf "Namespace from command line not equal to config's: %s != %s" ($namespace | quote) (.Release.Namespace | quote)) }}
10+
{{- end }}
11+
12+
apiVersion: apps/v1
13+
kind: Deployment
14+
metadata:
15+
name: {{ $name }}
16+
namespace: {{ $namespace }}
17+
spec:
18+
replicas: {{ .Values.replicas }}
19+
strategy:
20+
type: RollingUpdate
21+
rollingUpdate:
22+
maxSurge: 1
23+
maxUnavailable: 0
24+
selector:
25+
matchLabels:
26+
app: {{ $name }}
27+
template:
28+
metadata:
29+
labels:
30+
app: {{ $name }}
31+
spec:
32+
restartPolicy: Always
33+
containers:
34+
- name: {{ $name }}
35+
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
36+
imagePullPolicy: Always
37+
ports:
38+
- containerPort: {{ .Values.app.port }}
39+
volumeMounts:
40+
- name: localtime
41+
mountPath: /etc/localtime
42+
readOnly: true
43+
envFrom:
44+
- secretRef:
45+
name: omnibox-secrets
46+
readinessProbe:
47+
httpGet:
48+
path: /api/v1/health
49+
port: {{ .Values.app.port }}
50+
initialDelaySeconds: 15
51+
periodSeconds: 10
52+
livenessProbe:
53+
tcpSocket:
54+
port: {{ .Values.app.port }}
55+
initialDelaySeconds: 15
56+
periodSeconds: 10
57+
resources:
58+
requests:
59+
cpu: 128m
60+
memory: 256Mi
61+
limits:
62+
cpu: "1"
63+
memory: 2Gi
64+
volumes:
65+
- name: localtime
66+
hostPath:
67+
path: /etc/localtime
68+
type: File
69+
{{ if .Values.nodeSelector }}
70+
nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
71+
{{ end }}
72+
{{ if .Values.affinity }}
73+
affinity: {{ toYaml .Values.affinity | nindent 8 }}
74+
{{ end }}
75+
---
76+
apiVersion: v1
77+
kind: Service
78+
metadata:
79+
name: {{ $name }}
80+
namespace: {{ $namespace }}
81+
spec:
82+
selector:
83+
app: {{ $name }}
84+
ports:
85+
- protocol: TCP
86+
port: {{ .Values.app.port }}
87+
targetPort: {{ .Values.app.port }}
88+
type: ClusterIP

helm/backend/values.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
release:
2+
name: omnibox-backend
3+
namespace:
4+
5+
image:
6+
repository: ghcr.io/import-ai/omnibox-backend
7+
tag: main
8+
9+
replicas: 1
10+
11+
app:
12+
port: 8000
13+
14+
affinity: {}
15+
nodeSelector: {}

src/api-key/api-key.controller.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
APIKeyResponseDto,
44
CreateAPIKeyDto,
55
UpdateAPIKeyDto,
6+
PatchAPIKeyDto,
67
} from 'omniboxd/api-key/api-key.dto';
78
import {
89
BadRequestException,
@@ -11,6 +12,7 @@ import {
1112
Delete,
1213
Get,
1314
Param,
15+
Patch,
1416
Post,
1517
Put,
1618
Query,
@@ -53,6 +55,14 @@ export class APIKeyController {
5355
return await this.apiKeyService.update(id, updateApiKeyDto);
5456
}
5557

58+
@Patch(':id')
59+
async patch(
60+
@Param('id') id: string,
61+
@Body() patchApiKeyDto: PatchAPIKeyDto,
62+
): Promise<APIKeyResponseDto> {
63+
return await this.apiKeyService.patch(id, patchApiKeyDto);
64+
}
65+
5666
@Delete(':id')
5767
async delete(@Param('id') id: string): Promise<void> {
5868
return await this.apiKeyService.delete(id);

src/api-key/api-key.dto.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
import { IsOptional, IsString, IsUUID, IsObject } from 'class-validator';
2-
import { APIKeyAttrs } from './api-key.entity';
1+
import {
2+
IsOptional,
3+
IsString,
4+
IsUUID,
5+
IsObject,
6+
IsArray,
7+
ValidateNested,
8+
} from 'class-validator';
9+
import { Type } from 'class-transformer';
10+
import { APIKeyAttrs, APIKey, APIKeyPermission } from './api-key.entity';
311

412
export class CreateAPIKeyDto {
513
@IsString()
@@ -19,6 +27,18 @@ export class UpdateAPIKeyDto {
1927
attrs?: APIKeyAttrs;
2028
}
2129

30+
export class PatchAPIKeyDto {
31+
@IsString()
32+
@IsOptional()
33+
root_resource_id?: string;
34+
35+
@IsArray()
36+
@ValidateNested({ each: true })
37+
@Type(() => Object)
38+
@IsOptional()
39+
permissions?: APIKeyPermission[];
40+
}
41+
2242
export class APIKeyResponseDto {
2343
@IsUUID()
2444
id: string;
@@ -38,4 +58,16 @@ export class APIKeyResponseDto {
3858
created_at: Date;
3959

4060
updated_at: Date;
61+
62+
static fromEntity(apiKey: APIKey): APIKeyResponseDto {
63+
const dto = new APIKeyResponseDto();
64+
dto.id = apiKey.id;
65+
dto.value = apiKey.value;
66+
dto.user_id = apiKey.userId;
67+
dto.namespace_id = apiKey.namespaceId;
68+
dto.attrs = apiKey.attrs;
69+
dto.created_at = apiKey.createdAt;
70+
dto.updated_at = apiKey.updatedAt;
71+
return dto;
72+
}
4173
}

0 commit comments

Comments
 (0)