Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scoped Resources and Profiles and albums #31

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=

# --------------------------------------------------------------------------
# NGINX
# CADDY
# --------------------------------------------------------------------------

# This should be "on" if serving files through the API
Expand All @@ -116,7 +116,7 @@ DISCORD_CLIENT_SECRET=
PROXY_FILES=on

# --------------------------------------------------------------------------
# API and NGINX
# API and CADDY
# --------------------------------------------------------------------------

# File upload limit in megabytes
Expand Down
5 changes: 3 additions & 2 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ reqwest = { version = "0.11.11", features = [ "json" ] }
moka = { version = "0.9.4", features = ["future"] }
url = "2.3.1"
actix-cors = "0.6"
once_cell = "1.16.0"
8 changes: 0 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ FROM rust:1.60 as build
RUN USER=root cargo new --bin backpack
WORKDIR /backpack

# # copy over your manifests
# COPY Cargo.toml Cargo.lock ./
# COPY migration/Cargo.toml ./migration/Cargo.toml

# # Cache dependencies
# RUN cargo build --release
# RUN rm src/*.rs

# # Copy source
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ services:
env_file: .env
ports:
- ${PORT}:3000
volumes:
- $PWD/proxy/Caddyfile:/etc/caddy/Caddyfile
depends_on:
- backpack_api
- backpack_frontend
3 changes: 2 additions & 1 deletion frontend/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"@typescript-eslint/no-explicit-any": "off",
"react-hooks/rules-of-hooks": "off",
"react-hooks/exhaustive-deps": "off",
"@next/next/link-passhref": "off"
"@next/next/link-passhref": "off",
"@typescript-eslint/no-non-null-assertion": "off"
},
"ignorePatterns": ["client/**"]
}
9 changes: 6 additions & 3 deletions frontend/client/BackpackClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ import type { OpenAPIConfig } from './core/OpenAPI';
import { AxiosHttpRequest } from './core/AxiosHttpRequest';

import { AdminService } from './services/AdminService';
import { AlbumService } from './services/AlbumService';
import { ApplicationService } from './services/ApplicationService';
import { AuthenticationService } from './services/AuthenticationService';
import { FileService } from './services/FileService';
import { ServerService } from './services/ServerService';
import { UploadService } from './services/UploadService';
import { UserService } from './services/UserService';

type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;

export class BackpackClient {

public readonly admin: AdminService;
public readonly album: AlbumService;
public readonly application: ApplicationService;
public readonly authentication: AuthenticationService;
public readonly file: FileService;
public readonly server: ServerService;
public readonly upload: UploadService;
public readonly user: UserService;

public readonly request: BaseHttpRequest;
Expand All @@ -38,10 +40,11 @@ export class BackpackClient {
});

this.admin = new AdminService(this.request);
this.album = new AlbumService(this.request);
this.application = new ApplicationService(this.request);
this.authentication = new AuthenticationService(this.request);
this.file = new FileService(this.request);
this.server = new ServerService(this.request);
this.upload = new UploadService(this.request);
this.user = new UserService(this.request);
}
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/client/core/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* tslint:disable */
import axios from 'axios';
import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
import FormData from 'form-data';
import * as FormData from 'form-data';

import { ApiError } from './ApiError';
import type { ApiRequestOptions } from './ApiRequestOptions';
Expand Down
12 changes: 8 additions & 4 deletions frontend/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export { CancelablePromise, CancelError } from './core/CancelablePromise';
export { OpenAPI } from './core/OpenAPI';
export type { OpenAPIConfig } from './core/OpenAPI';

export type { AlbumCreate } from './models/AlbumCreate';
export type { AlbumData } from './models/AlbumData';
export type { AlbumUpdate } from './models/AlbumUpdate';
export type { AppInfo } from './models/AppInfo';
export type { ApplicationCreate } from './models/ApplicationCreate';
export type { ApplicationData } from './models/ApplicationData';
Expand All @@ -17,9 +20,6 @@ export type { BasicAuthForm } from './models/BasicAuthForm';
export type { BatchDeleteRequest } from './models/BatchDeleteRequest';
export type { BatchDeleteResponse } from './models/BatchDeleteResponse';
export type { BatchFileError } from './models/BatchFileError';
export type { FileData } from './models/FileData';
export type { FilePage } from './models/FilePage';
export type { FileStats } from './models/FileStats';
export type { LoginRedirectUrl } from './models/LoginRedirectUrl';
export type { MessageResponse } from './models/MessageResponse';
export { OAuthProvider } from './models/OAuthProvider';
Expand All @@ -31,15 +31,19 @@ export type { TokenResponse } from './models/TokenResponse';
export type { UnlinkAuthMethod } from './models/UnlinkAuthMethod';
export type { UpdateUserSettings } from './models/UpdateUserSettings';
export type { UploadConflict } from './models/UploadConflict';
export type { UploadData } from './models/UploadData';
export type { UploadFile } from './models/UploadFile';
export type { UploadPage } from './models/UploadPage';
export type { UploadStats } from './models/UploadStats';
export type { UserCreateForm } from './models/UserCreateForm';
export type { UserData } from './models/UserData';
export type { UserDeleteForm } from './models/UserDeleteForm';
export { UserRole } from './models/UserRole';

export { AdminService } from './services/AdminService';
export { AlbumService } from './services/AlbumService';
export { ApplicationService } from './services/ApplicationService';
export { AuthenticationService } from './services/AuthenticationService';
export { FileService } from './services/FileService';
export { ServerService } from './services/ServerService';
export { UploadService } from './services/UploadService';
export { UserService } from './services/UserService';
18 changes: 18 additions & 0 deletions frontend/client/models/AlbumCreate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* istanbul ignore file */
/* tslint:disable */

export type AlbumCreate = {
/**
* Optional album description.
*/
description?: string;
/**
* Album name.
*/
name: string;
/**
* Is the album public.
*/
public: boolean;
};

24 changes: 24 additions & 0 deletions frontend/client/models/AlbumData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* istanbul ignore file */
/* tslint:disable */

export type AlbumData = {
/**
* Date of album creation
*/
created: string;
/**
* Optional album description
*/
description?: string;
id: string;
name: string;
/**
* Is the album public.
*/
public: boolean;
/**
* User who created the album.
*/
userId: string;
};

18 changes: 18 additions & 0 deletions frontend/client/models/AlbumUpdate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* istanbul ignore file */
/* tslint:disable */

export type AlbumUpdate = {
/**
* Optional album description.
*/
description?: string;
/**
* Album name.
*/
name?: string;
/**
* Is the album public.
*/
public?: boolean;
};

11 changes: 0 additions & 11 deletions frontend/client/models/FilePage.ts

This file was deleted.

4 changes: 2 additions & 2 deletions frontend/client/models/UploadConflict.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* istanbul ignore file */
/* tslint:disable */

import type { FileData } from './FileData';
import type { UploadData } from './UploadData';

/**
* Identical file was already uploaded.
*/
export type UploadConflict = {
file: FileData;
message: string;
upload: UploadData;
};

Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* istanbul ignore file */
/* tslint:disable */

export type FileData = {
export type UploadData = {
albumId?: string;
hash: string;
id: string;
name: string;
originalName: string;
public: boolean;
size: number;
thumbnailUrl?: string;
uploaded: number;
Expand Down
11 changes: 11 additions & 0 deletions frontend/client/models/UploadPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* istanbul ignore file */
/* tslint:disable */

import type { UploadData } from './UploadData';

export type UploadPage = {
items: Array<UploadData>;
page: number;
pages: number;
};

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/**
* File stats for user.
*/
export type FileStats = {
export type UploadStats = {
/**
* Total usage in bytes
*/
Expand Down
12 changes: 9 additions & 3 deletions frontend/client/models/UserData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
import type { UserRole } from './UserRole';

export type UserData = {
email: string;
/**
* This will not be present if accessed by another user.
*/
email?: string;
id: string;
/**
* Has the user already verified with a registration key?
*/
registered: boolean;
registered?: boolean;
role: UserRole;
username: string;
verified: boolean;
/**
* This will not be present if accessed by another user.
*/
verified?: boolean;
};

3 changes: 0 additions & 3 deletions frontend/client/services/AdminService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class AdminService {

/**
* Get registration keys
* - Minimum required role: `admin`
* - Allow unverified users: `false`
* - Application token allowed: `false`
*
Expand All @@ -60,7 +59,6 @@ export class AdminService {

/**
* Get a single registration key
* - Minimum required role: `admin`
* - Allow unverified users: `false`
* - Application token allowed: `false`
*
Expand All @@ -85,7 +83,6 @@ export class AdminService {

/**
* Delete a registration key
* - Minimum required role: `admin`
* - Allow unverified users: `false`
* - Application token allowed: `false`
*
Expand Down
Loading