Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pp2amd6 committed Oct 15, 2023
2 parents f232346 + 02a5f3f commit cb65ffc
Show file tree
Hide file tree
Showing 303 changed files with 678 additions and 560 deletions.
7 changes: 6 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"ecmaVersion": 2021,
"sourceType": "module",
"project": "./tsconfig.base.json",
"emitDecoratorMetadata": true,
"ecmaFeatures": {
"jsx": true
}
Expand All @@ -26,6 +27,10 @@
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/no-unused-vars": "off"
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/consistent-type-imports": [
"error",
{ "prefer": "type-imports", "fixStyle": "inline-type-imports" }
]
}
}
2 changes: 1 addition & 1 deletion apps/api/src/controllers/admin/admin-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { join } from "node:path";
import { stat } from "node:fs/promises";
import { Res, UseBefore } from "@tsed/common";
import { IsAuth } from "middlewares/auth/is-auth";
import { Prisma, WhitelistStatus } from "@prisma/client";
import { type Prisma, WhitelistStatus } from "@prisma/client";
import { UsePermissions } from "middlewares/use-permissions";
import { defaultPermissions, Permissions } from "@snailycad/permissions";
import type { GetAdminDashboardData } from "@snailycad/types/api";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
QueryParams,
BodyParams,
MultipartFile,
PlatformMulterFile,
type PlatformMulterFile,
UseBeforeEach,
} from "@tsed/common";
import { IsAuth } from "middlewares/auth/is-auth";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
BodyParams,
MultipartFile,
PathParams,
PlatformMulterFile,
type PlatformMulterFile,
QueryParams,
UseBeforeEach,
} from "@tsed/common";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
BodyParams,
MultipartFile,
PathParams,
PlatformMulterFile,
type PlatformMulterFile,
QueryParams,
UseBeforeEach,
} from "@tsed/common";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ import { ContentType, Delete, Description, Get, Post, Put } from "@tsed/schema";
import { prisma } from "lib/data/prisma";
import { CAD_SELECT, IsAuth, setCADFeatures } from "middlewares/auth/is-auth";
import { BadRequest, NotFound } from "@tsed/exceptions";
import { MultipartFile, PlatformMulterFile, Req, Res, UseBefore } from "@tsed/common";
import { MultipartFile, type PlatformMulterFile, Req, Res, UseBefore } from "@tsed/common";
import { Socket } from "services/socket-service";
import { nanoid } from "nanoid";
import { validateSchema } from "lib/data/validate-schema";
import { ApiToken, cad, Feature, JailTimeScale, Prisma } from "@prisma/client";
import {
type ApiToken,
type cad,
type Feature,
type JailTimeScale,
type Prisma,
} from "@prisma/client";
import { getCADVersion } from "@snailycad/utils/version";
import { getSessionUser, userProperties } from "lib/auth/getSessionUser";
import type * as APITypes from "@snailycad/types/api";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { ContentType, Post } from "@tsed/schema";
import { prisma } from "lib/data/prisma";
import { CAD_SELECT, IsAuth } from "middlewares/auth/is-auth";
import { BadRequest } from "@tsed/exceptions";
import { MultipartFile, PlatformMulterFile, UseBefore } from "@tsed/common";
import { AllowedFileExtension, allowedFileExtensions } from "@snailycad/config";
import { MultipartFile, type PlatformMulterFile, UseBefore } from "@tsed/common";
import { type AllowedFileExtension, allowedFileExtensions } from "@snailycad/config";
import fs from "node:fs/promises";
import { cad, Feature, MiscCadSettings } from "@prisma/client";
import { type cad, type Feature, type MiscCadSettings } from "@prisma/client";
import { Permissions, hasPermission } from "@snailycad/permissions";
import { UsePermissions } from "middlewares/use-permissions";
import { ExtendedBadRequest } from "src/exceptions/extended-bad-request";
import { getImageWebPPath } from "lib/images/get-image-webp-path";
import { AuditLogActionType, createAuditLogEntry } from "@snailycad/audit-logger/server";
import type { User } from "@snailycad/types";
import { User } from "@snailycad/types";
import { resolve } from "node:path";
import { existsSync } from "node:fs";
import sharp from "sharp";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import process from "node:process";
import { BodyParams, Context, Controller, UseBeforeEach } from "@tsed/common";
import { ContentType, Get, Post } from "@tsed/schema";
import { RESTGetAPIGuildRolesResult, Routes } from "discord-api-types/v10";
import { type RESTGetAPIGuildRolesResult, Routes } from "discord-api-types/v10";
import { IsAuth } from "middlewares/auth/is-auth";
import { prisma } from "lib/data/prisma";
import { cad, DiscordRole } from "@prisma/client";
import { type cad, type DiscordRole } from "@prisma/client";
import { BadRequest } from "@tsed/exceptions";
import { DISCORD_SETTINGS_SCHEMA } from "@snailycad/schemas";
import { validateSchema } from "lib/data/validate-schema";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ import process from "node:process";
import { BodyParams, Context, Controller, UseBeforeEach } from "@tsed/common";
import { ContentType, Get, Post } from "@tsed/schema";
import {
APITextChannel,
type APITextChannel,
ChannelType,
RESTGetAPIGuildChannelsResult,
RESTGetAPIWebhookResult,
type RESTGetAPIGuildChannelsResult,
type RESTGetAPIWebhookResult,
Routes,
} from "discord-api-types/v10";
import { IsAuth } from "middlewares/auth/is-auth";
import { prisma } from "lib/data/prisma";
import { cad, DiscordWebhook, DiscordWebhookType, MiscCadSettings } from "@prisma/client";
import {
type cad,
type DiscordWebhook,
type DiscordWebhookType,
type MiscCadSettings,
} from "@prisma/client";
import { BadRequest } from "@tsed/exceptions";
import { DISCORD_WEBHOOKS_SCHEMA } from "@snailycad/schemas";
import { validateSchema } from "lib/data/validate-schema";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { BodyParams, Context } from "@tsed/platform-params";
import { ContentType, Put } from "@tsed/schema";
import { prisma } from "lib/data/prisma";
import { IsAuth } from "middlewares/auth/is-auth";
import { MultipartFile, PlatformMulterFile, UseBefore } from "@tsed/common";
import { MultipartFile, type PlatformMulterFile, UseBefore } from "@tsed/common";
import { validateSchema } from "lib/data/validate-schema";
import { cad } from "@prisma/client";
import { type cad } from "@prisma/client";
import type * as APITypes from "@snailycad/types/api";
import { Permissions, UsePermissions } from "middlewares/use-permissions";
import { AuditLogActionType, createAuditLogEntry } from "@snailycad/audit-logger/server";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { DiscordWebhookType, RawWebhook } from "@prisma/client";
import { AuditLogActionType, createAuditLogEntry } from "@snailycad/audit-logger/server";
import { RAW_WEBHOOKS_SCHEMA } from "@snailycad/schemas";
import { cad } from "@snailycad/types";
import { type cad } from "@snailycad/types";
import { BodyParams, Context, UseBeforeEach } from "@tsed/common";
import { Controller } from "@tsed/di";
import { ContentType, Get, Post } from "@tsed/schema";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Prisma, WhitelistStatus } from "@prisma/client";
import { UsePermissions, Permissions } from "middlewares/use-permissions";

import type * as APITypes from "@snailycad/types/api";
import { AcceptDeclineType, ACCEPT_DECLINE_TYPES } from "../units/manage-units-controller";
import { type AcceptDeclineType, ACCEPT_DECLINE_TYPES } from "../units/manage-units-controller";
import { BadRequest, NotFound } from "@tsed/exceptions";

export const recordsLogsInclude = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Warrant, WarrantStatus, WhitelistStatus } from "@prisma/client";
import { type Warrant, WarrantStatus, WhitelistStatus } from "@prisma/client";
import { Controller } from "@tsed/di";
import { BadRequest, NotFound } from "@tsed/exceptions";
import { UseBeforeEach } from "@tsed/platform-middlewares";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Prisma, WhitelistStatus } from "@prisma/client";
import { type Prisma, WhitelistStatus } from "@prisma/client";
import { Controller } from "@tsed/di";
import { NotFound } from "@tsed/exceptions";
import { UseBeforeEach } from "@tsed/platform-middlewares";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CustomFieldCategory, Prisma } from "@prisma/client";
import { type CustomFieldCategory, type Prisma } from "@prisma/client";
import { AuditLogActionType, createAuditLogEntry } from "@snailycad/audit-logger/server";
import { CUSTOM_FIELDS_SCHEMA } from "@snailycad/schemas";
import { BodyParams, Context, PathParams, QueryParams, UseBeforeEach } from "@tsed/common";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Prisma } from "@prisma/client";
import { AllowedFileExtension, allowedFileExtensions } from "@snailycad/config";
import { type Prisma } from "@prisma/client";
import { type AllowedFileExtension, allowedFileExtensions } from "@snailycad/config";
import { CUSTOM_ROLE_SCHEMA } from "@snailycad/schemas";
import {
BodyParams,
Context,
MultipartFile,
PathParams,
PlatformMulterFile,
type PlatformMulterFile,
QueryParams,
UseBeforeEach,
} from "@tsed/common";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import {
Rank,
WhitelistStatus,
User,
type User,
Prisma,
CustomRole,
type CustomRole,
DiscordWebhookType,
} from "@prisma/client";
import { PathParams, BodyParams, Context, QueryParams } from "@tsed/common";
Expand Down Expand Up @@ -34,7 +34,7 @@ import { AuditLogActionType, createAuditLogEntry } from "@snailycad/audit-logger
import { isDiscordIdInUse } from "lib/discord/utils";
import { getTranslator } from "~/utils/get-translator";
import { sendRawWebhook, sendDiscordWebhook } from "~/lib/discord/webhooks";
import { APIEmbed } from "discord-api-types/v10";
import { type APIEmbed } from "discord-api-types/v10";

const manageUsersSelect = (selectCitizens: boolean) =>
({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import {
Feature,
WhitelistStatus,
cad,
MiscCadSettings,
type cad,
type MiscCadSettings,
DiscordWebhookType,
Officer,
type Officer,
} from "@prisma/client";
import { UPDATE_UNIT_SCHEMA, UPDATE_UNIT_CALLSIGN_SCHEMA } from "@snailycad/schemas";
import {
Expand All @@ -14,7 +14,7 @@ import {
Context,
QueryParams,
MultipartFile,
PlatformMulterFile,
type PlatformMulterFile,
} from "@tsed/common";
import { Controller } from "@tsed/di";
import { BadRequest, NotFound } from "@tsed/exceptions";
Expand All @@ -33,7 +33,7 @@ import { ExtendedBadRequest } from "src/exceptions/extended-bad-request";
import { manyToManyHelper } from "lib/data/many-to-many";
import type * as APITypes from "@snailycad/types/api";
import { isFeatureEnabled } from "lib/upsert-cad";
import { AllowedFileExtension, allowedFileExtensions } from "@snailycad/config";
import { type AllowedFileExtension, allowedFileExtensions } from "@snailycad/config";
import { validateImageURL } from "lib/images/validate-image-url";
import generateBlurPlaceholder from "lib/images/generate-image-blur-data";
import fs from "node:fs/promises";
Expand All @@ -48,9 +48,9 @@ import {
combinedEmsFdUnitProperties,
} from "utils/leo/includes";
import { getTranslator } from "~/utils/get-translator";
import { APIEmbed } from "discord-api-types/v10";
import { type APIEmbed } from "discord-api-types/v10";
import { sendRawWebhook, sendDiscordWebhook } from "~/lib/discord/webhooks";
import { Citizen, EmsFdDeputy, LeoWhitelistStatus } from "@snailycad/types";
import { type Citizen, type EmsFdDeputy, type LeoWhitelistStatus } from "@snailycad/types";
import { generateCallsign } from "@snailycad/utils";

const ACTIONS = ["SET_DEPARTMENT_DEFAULT", "SET_DEPARTMENT_NULL", "DELETE_UNIT"] as const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PathParams,
UseBeforeEach,
MultipartFile,
PlatformMulterFile,
type PlatformMulterFile,
Context,
} from "@tsed/common";
import { ContentType, Post } from "@tsed/schema";
Expand Down Expand Up @@ -36,10 +36,10 @@ import {
type QualificationValueType,
WhatPages,
ValueType,
Value,
cad,
PenalCodeType,
Feature,
type Value,
type cad,
type PenalCodeType,
type Feature,
} from "@prisma/client";
import { validateSchema } from "lib/data/validate-schema";
import { upsertWarningApplicable } from "~/lib/leo/records/penal-code";
Expand Down
10 changes: 7 additions & 3 deletions apps/api/src/controllers/admin/values/values-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
BodyParams,
QueryParams,
MultipartFile,
PlatformMulterFile,
type PlatformMulterFile,
Context,
} from "@tsed/common";
import fs from "node:fs/promises";
Expand All @@ -17,10 +17,14 @@ import { BadRequest, NotFound } from "@tsed/exceptions";
import { IsAuth } from "middlewares/auth/is-auth";
import { typeHandlers } from "./import-values-controller";
import { ExtendedBadRequest } from "src/exceptions/extended-bad-request";
import { ValuesSelect, getTypeFromPath, getPermissionsForValuesRequest } from "lib/values/utils";
import {
type ValuesSelect,
getTypeFromPath,
getPermissionsForValuesRequest,
} from "lib/values/utils";
import { ValueType } from "@prisma/client";
import { UsePermissions } from "middlewares/use-permissions";
import { AllowedFileExtension, allowedFileExtensions } from "@snailycad/config";
import { type AllowedFileExtension, allowedFileExtensions } from "@snailycad/config";
import type * as APITypes from "@snailycad/types/api";
import { getImageWebPPath } from "lib/images/get-image-webp-path";
import { BULK_DELETE_SCHEMA } from "@snailycad/schemas";
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/controllers/auth/2fa-controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { User } from "@prisma/client";
import { User } from "@prisma/client";
import process from "node:process";
import { authenticator } from "otplib";
import { BodyParams, Context, UseBeforeEach } from "@tsed/common";
Expand Down
11 changes: 9 additions & 2 deletions apps/api/src/controllers/auth/auth-controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, BodyParams, Post, Res, Response } from "@tsed/common";
import { Controller, BodyParams, Post, Res, type Response } from "@tsed/common";
import { hashSync, genSaltSync, compareSync } from "bcrypt";
import { BadRequest } from "@tsed/exceptions";
import { prisma } from "lib/data/prisma";
Expand All @@ -9,7 +9,14 @@ import { ExtendedNotFound } from "src/exceptions/extended-not-found";
import { ExtendedBadRequest } from "src/exceptions/extended-bad-request";
import { validateUser2FA } from "lib/auth/2fa";
import { ContentType, Description, Returns } from "@tsed/schema";
import { User, WhitelistStatus, Rank, AutoSetUserProperties, cad, Feature } from "@prisma/client";
import {
type User,
WhitelistStatus,
Rank,
type AutoSetUserProperties,
type cad,
Feature,
} from "@prisma/client";
import { defaultPermissions, Permissions } from "@snailycad/permissions";
import { setUserPreferencesCookies } from "lib/auth/setUserPreferencesCookies";
import type * as APITypes from "@snailycad/types/api";
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/controllers/auth/discord-auth-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { request } from "undici";
import type { RESTPostOAuth2AccessTokenResult, APIUser } from "discord-api-types/v10";
import { prisma } from "lib/data/prisma";
import { getSessionUser } from "lib/auth/getSessionUser";
import { cad, Feature, Rank, WhitelistStatus, type User } from "@prisma/client";
import { type cad, Feature, Rank, WhitelistStatus, type User } from "@prisma/client";
import { getDefaultPermissionsForNewUser } from "./auth-controller";
import { IsAuth } from "middlewares/auth/is-auth";
import { DISCORD_API_URL } from "lib/discord/config";
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/controllers/auth/steam-auth-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BadRequest } from "@tsed/exceptions";
import { Controller } from "@tsed/di";
import { URL } from "node:url";
import { prisma } from "lib/data/prisma";
import { Rank, User, WhitelistStatus } from "@prisma/client";
import { Rank, type User, WhitelistStatus } from "@prisma/client";
import { IsAuth } from "middlewares/auth/is-auth";
import { ContentType, Description } from "@tsed/schema";
import { request } from "undici";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApiToken, User } from "@snailycad/types";
import { type ApiToken, type User } from "@snailycad/types";
import { BodyParams, Context } from "@tsed/common";
import { Controller } from "@tsed/di";
import { BadRequest } from "@tsed/exceptions";
Expand Down
10 changes: 8 additions & 2 deletions apps/api/src/controllers/auth/user/user-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { Cookie } from "@snailycad/config";
import { prisma } from "lib/data/prisma";
import { IsAuth } from "middlewares/auth/is-auth";
import { setCookie } from "utils/set-cookie";
import { cad, Rank, ShouldDoType, StatusViewMode, TableActionsAlignment } from "@prisma/client";
import {
type cad,
Rank,
ShouldDoType,
type StatusViewMode,
type TableActionsAlignment,
} from "@prisma/client";
import { NotFound } from "@tsed/exceptions";
import {
CHANGE_PASSWORD_SCHEMA,
Expand All @@ -21,7 +27,7 @@ import { Socket } from "services/socket-service";
import { handleStartEndOfficerLog } from "lib/leo/handleStartEndOfficerLog";
import { setUserPreferencesCookies } from "lib/auth/setUserPreferencesCookies";
import type * as APITypes from "@snailycad/types/api";
import type { User } from "@snailycad/types";
import { User } from "@snailycad/types";
import { getActiveOfficer } from "~/lib/leo/activeOfficer";
import { getActiveDeputy } from "~/lib/get-active-ems-fd-deputy";

Expand Down
Loading

0 comments on commit cb65ffc

Please sign in to comment.