Skip to content

Commit

Permalink
Update swagger and routes and cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
Francis Duvivier committed Jan 19, 2025
1 parent 2ae6feb commit c3f6474
Show file tree
Hide file tree
Showing 11 changed files with 254 additions and 211 deletions.
324 changes: 179 additions & 145 deletions public/swagger.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { config } from "dotenv";
import * as path from "node:path";

config();
export const EXPRESS_PORT = 8081;
Expand Down
2 changes: 0 additions & 2 deletions src/controllers/private-rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Patch,
Path,
Post,
Request,
Route,
Tags,
UploadedFile,
Expand All @@ -17,7 +16,6 @@ import type { DBInsertUser, DBUser } from "@db/models/app/DBUser";
import type { DBInsertProject } from "@db/models/app/DBProject";
import type { DBInsertAppMetadataJSON } from "@db/models/app/DBAppMetadataJSON";
import { NodeFSBadgeHubFiles } from "@fs/NodeFSBadgeHubFiles";
import express from "express";
import { Readable } from "node:stream";

interface UserProps extends Omit<DBInsertUser, "id"> {}
Expand Down
5 changes: 1 addition & 4 deletions src/db/PostgreSQLBadgeHubMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import { Version } from "@domain/readModels/app/Version";
import { Category } from "@domain/readModels/app/Category";
import { Pool } from "pg";
import { getPool } from "@db/connectionPool";
import {
DBInsertProject,
DBProject as DBProject,
} from "@db/models/app/DBProject";
import { DBInsertProject } from "@db/models/app/DBProject";
import sql, { join, raw } from "sql-template-tag";
import { DBInsertUser } from "@db/models/app/DBUser";
import { getEntriesWithDefinedValues } from "@util/objectEntries";
Expand Down
1 change: 0 additions & 1 deletion src/db/models/app/DBFileMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { UserRelation } from "./DBUser";
import { DBDatedData } from "./DBDatedData";
import { VersionRelation } from "@db/models/app/DBVersion";

Expand Down
2 changes: 1 addition & 1 deletion src/domain/BadgeHubData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ProjectSlug,
ProjectWithoutVersion,
} from "@domain/readModels/app/Project";
import { Version, VersionRevision } from "@domain/readModels/app/Version";
import { Version } from "@domain/readModels/app/Version";
import { User } from "@domain/readModels/app/User";
import { FileMetadata } from "@domain/readModels/app/FileMetadata";
import { Badge } from "@domain/readModels/Badge";
Expand Down
2 changes: 0 additions & 2 deletions src/domain/readModels/app/FileMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { VersionRelation } from "./Version";
import { UserRelation } from "./User";
import { DatedData } from "./DatedData";

export interface FileMetadata extends DatedData {
Expand Down
123 changes: 71 additions & 52 deletions src/generated/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const models: TsoaRoute.Models = {
{ dataType: "enum", enums: ["Unusable"] },
{ dataType: "enum", enums: ["Adult"] },
{ dataType: "enum", enums: ["Virus"] },
{ dataType: "enum", enums: ["SAO"] },
{ dataType: "enum", enums: ["Interpreter"] },
],
validators: {},
Expand Down Expand Up @@ -78,67 +79,22 @@ const models: TsoaRoute.Models = {
},
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
Version: {
dataType: "refObject",
properties: {
created_at: { dataType: "datetime", required: true },
updated_at: { dataType: "datetime", required: true },
deleted_at: { dataType: "datetime" },
revision: { dataType: "double", required: true },
semantic_version: { dataType: "string" },
zip: { dataType: "string" },
size_of_zip: { dataType: "double" },
git_commit_id: { dataType: "string" },
files: {
dataType: "array",
array: { dataType: "refObject", ref: "FileMetadata" },
required: true,
},
app_metadata: { ref: "AppMetadataJSON", required: true },
published_at: { dataType: "datetime" },
download_count: { dataType: "double", required: true },
project_slug: { dataType: "string", required: true },
},
additionalProperties: false,
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
User: {
dataType: "refObject",
properties: {
created_at: { dataType: "datetime", required: true },
updated_at: { dataType: "datetime", required: true },
deleted_at: { dataType: "datetime" },
id: { dataType: "double", required: true },
email: { dataType: "string", required: true },
admin: { dataType: "boolean", required: true },
name: { dataType: "string", required: true },
password: { dataType: "string", required: true },
remember_token: { dataType: "string" },
editor: { dataType: "string", required: true },
public: { dataType: "boolean", required: true },
show_projects: { dataType: "boolean", required: true },
email_verified_at: { dataType: "datetime" },
},
additionalProperties: false,
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
FileMetadata: {
dataType: "refObject",
properties: {
version: { ref: "Version", required: true },
user: { ref: "User", required: true },
created_at: { dataType: "datetime", required: true },
updated_at: { dataType: "datetime", required: true },
deleted_at: { dataType: "datetime" },
editable: { dataType: "boolean" },
lintable: { dataType: "boolean" },
extension: { dataType: "string", required: true },
baseName: { dataType: "string", required: true },
mime: { dataType: "string" },
dir: { dataType: "string", required: true },
name: { dataType: "string", required: true },
ext: { dataType: "string", required: true },
mimetype: { dataType: "string", required: true },
size_of_content: { dataType: "double", required: true },
crc32: { dataType: "string", required: true },
sha256: { dataType: "string", required: true },
confirmed_in_sync_on_disk: { dataType: "boolean", required: true },
size_formatted: { dataType: "string", required: true },
name: { dataType: "string", required: true },
full_path: { dataType: "string", required: true },
},
additionalProperties: false,
},
Expand Down Expand Up @@ -204,6 +160,30 @@ const models: TsoaRoute.Models = {
additionalProperties: false,
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
Version: {
dataType: "refObject",
properties: {
created_at: { dataType: "datetime", required: true },
updated_at: { dataType: "datetime", required: true },
deleted_at: { dataType: "datetime" },
revision: { dataType: "double", required: true },
semantic_version: { dataType: "string" },
zip: { dataType: "string" },
size_of_zip: { dataType: "double" },
git_commit_id: { dataType: "string" },
files: {
dataType: "array",
array: { dataType: "refObject", ref: "FileMetadata" },
required: true,
},
app_metadata: { ref: "AppMetadataJSON", required: true },
published_at: { dataType: "datetime" },
download_count: { dataType: "double", required: true },
project_slug: { dataType: "string", required: true },
},
additionalProperties: false,
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
ProjectSlug: {
dataType: "refAlias",
type: { dataType: "string", validators: {} },
Expand All @@ -230,6 +210,26 @@ const models: TsoaRoute.Models = {
additionalProperties: false,
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
User: {
dataType: "refObject",
properties: {
created_at: { dataType: "datetime", required: true },
updated_at: { dataType: "datetime", required: true },
deleted_at: { dataType: "datetime" },
id: { dataType: "double", required: true },
email: { dataType: "string", required: true },
admin: { dataType: "boolean", required: true },
name: { dataType: "string", required: true },
password: { dataType: "string", required: true },
remember_token: { dataType: "string" },
editor: { dataType: "string", required: true },
public: { dataType: "boolean", required: true },
show_projects: { dataType: "boolean", required: true },
email_verified_at: { dataType: "datetime" },
},
additionalProperties: false,
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
VoteFromUser: {
dataType: "refObject",
properties: {
Expand Down Expand Up @@ -318,6 +318,16 @@ const models: TsoaRoute.Models = {
additionalProperties: false,
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
"Exclude_Project.version_": {
dataType: "refAlias",
type: { ref: "Project", validators: {} },
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
ProjectWithoutVersion: {
dataType: "refAlias",
type: { ref: "Exclude_Project.version_", validators: {} },
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
Uint8Array: {
dataType: "refObject",
properties: {},
Expand Down Expand Up @@ -365,6 +375,9 @@ const models: TsoaRoute.Models = {
dataType: "nestedObjectLiteral",
nestedProperties: {
version_id: { dataType: "double" },
created_at: { dataType: "string" },
updated_at: { dataType: "string" },
deleted_at: { dataType: "string" },
git: { dataType: "string" },
allow_team_fixes: { dataType: "boolean" },
user_id: { dataType: "double", required: true },
Expand All @@ -377,6 +390,9 @@ const models: TsoaRoute.Models = {
dataType: "refObject",
properties: {
version_id: { dataType: "double" },
created_at: { dataType: "string" },
updated_at: { dataType: "string" },
deleted_at: { dataType: "string" },
git: { dataType: "string" },
allow_team_fixes: { dataType: "boolean" },
user_id: { dataType: "double", required: true },
Expand All @@ -388,6 +404,9 @@ const models: TsoaRoute.Models = {
dataType: "refObject",
properties: {
version_id: { dataType: "double" },
created_at: { dataType: "string" },
updated_at: { dataType: "string" },
deleted_at: { dataType: "string" },
git: { dataType: "string" },
allow_team_fixes: { dataType: "boolean" },
user_id: { dataType: "double" },
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ async function startServer() {
});
}

// noinspection JSIgnoredPromiseFromCall
startServer();
3 changes: 1 addition & 2 deletions src/setupPopulateDBApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { DBInsertProjectStatusOnBadge } from "@db/models/DBProjectStatusOnBadge"
import { BadgeHubData } from "@domain/BadgeHubData";
import { PostgreSQLBadgeHubMetadata } from "@db/PostgreSQLBadgeHubMetadata";
import { NodeFSBadgeHubFiles } from "@fs/NodeFSBadgeHubFiles";
import * as fs from "node:fs";
import { stringToNumberDigest } from "@util/digests";

const CATEGORY_NAMES = [
Expand All @@ -44,7 +43,7 @@ const BADGES = ["mch2022", "troopers23", "WHY2025"] as const; // Hardcoded! Upda
const badgeSlugs = BADGES.map(nameToSlug); // Hardcoded! Update by hand

const CATEGORIES_COUNT = CATEGORY_NAMES.length;
export default async function setupPopulateDBApi(app: Express) {
export default function setupPopulateDBApi(app: Express) {
const router = Router();

app.use(express.json());
Expand Down
1 change: 0 additions & 1 deletion src/util/digests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ProjectSlug } from "@domain/readModels/app/Project";
import { subtle } from "node:crypto";
import { UploadedFile } from "@domain/UploadedFile";

Expand Down

0 comments on commit c3f6474

Please sign in to comment.