Skip to content

Commit e60a6fc

Browse files
authored
Merge branch 'main' into api-improvements
2 parents df3bfa0 + c219bfe commit e60a6fc

57 files changed

Lines changed: 11887 additions & 18975 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
node_modules
1+
node_modules
2+
.git
3+
*.log
4+
*.env
5+
Dockerfile
6+
.dockerignore
7+
__tests__/
8+
coverage/
9+
dist/

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111

1212
strategy:
1313
matrix:
14-
node-version: [18.x, 20.x]
14+
node-version: [20.x, 22.x]
1515

1616
steps:
1717
- uses: actions/checkout@v4

.github/workflows/test-builds-typecheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
os: [ubuntu-latest, windows-latest]
16-
node-version: [18.x, 20.x]
16+
node-version: [20.x, 22.x]
1717

1818
steps:
1919
- uses: actions/checkout@v4

Dockerfile

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,35 @@
1-
FROM node:18 as base
2-
3-
RUN npm install -g pnpm
4-
5-
RUN pnpm config set httpTimeout 1200000
1+
FROM node:20-slim AS base
62

73
WORKDIR /snailycad
84

5+
# Install pnpm globally and set config in one layer
6+
RUN npm install -g pnpm && pnpm config set httpTimeout 1200000
7+
8+
# Copy the rest of the source code
99
COPY . ./
1010

11-
FROM base as deps
11+
FROM base AS deps
1212

13-
RUN pnpm install
13+
RUN pnpm install --frozen-lockfile
1414

15-
FROM deps as api
15+
FROM deps AS build
1616

1717
ENV NODE_ENV="production"
1818

19-
RUN pnpm turbo run build --filter=@snailycad/api
19+
# Build all packages (this will also build the API and Client)
20+
RUN pnpm turbo run build --filter="{packages/*}"
2021

21-
WORKDIR /snailycad/apps/api
2222

23+
FROM build AS api
24+
ENV NODE_ENV="production"
25+
WORKDIR /snailycad/apps/api
26+
RUN pnpm run build
2327
CMD ["pnpm", "start"]
2428

25-
FROM deps as client
26-
29+
FROM build AS client
2730
ENV NODE_ENV="production"
28-
31+
WORKDIR /snailycad/apps/client
2932
RUN rm -rf /snailycad/apps/client/.next
30-
3133
RUN pnpm create-images-domain
32-
33-
RUN pnpm turbo run build --filter=@snailycad/client
34-
35-
WORKDIR /snailycad/apps/client
36-
34+
RUN pnpm run build
3735
CMD ["pnpm", "start"]

apps/api/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"nodemon": "^3.1.3",
8585
"otplib": "^12.0.1",
8686
"prisma": "^5.15.0",
87-
"puppeteer": "^21.5.2",
87+
"puppeteer": "^24.11.1",
8888
"qrcode": "^1.5.3",
8989
"reflect-metadata": "^0.2.2",
9090
"sharp": "^0.33.4",
@@ -93,6 +93,6 @@
9393
"tslib": "^2.6.3",
9494
"undici": "^6.18.2",
9595
"use-intl": "2.22.1",
96-
"zod": "^3.23.8"
96+
"zod": "3.25.67"
9797
}
9898
}

apps/api/src/controllers/admin/values/import-values-controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,15 +576,15 @@ export const typeHandlers = {
576576
data.map((item) => {
577577
const data = {
578578
update: {
579-
isDefault: type === ValueType.LICENSE ? item.isDefault ?? false : false,
579+
isDefault: type === ValueType.LICENSE ? (item.isDefault ?? false) : false,
580580
type: type as ValueType,
581581
value: { set: item.value },
582582
licenseType:
583583
type === ValueType.LICENSE ? (item.licenseType as ValueLicenseType) : undefined,
584584
isDisabled: item.isDisabled ?? false,
585585
},
586586
create: {
587-
isDefault: type === ValueType.LICENSE ? item.isDefault ?? false : false,
587+
isDefault: type === ValueType.LICENSE ? (item.isDefault ?? false) : false,
588588
type: type as ValueType,
589589
value: item.value,
590590
isDisabled: item.isDisabled ?? false,

apps/api/src/controllers/dispatch/911-calls/calls-911-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export class Calls911Controller {
315315
description: data.descriptionData ? null : data.description,
316316
name: data.name,
317317
userId: user.id,
318-
positionId: shouldRemovePosition ? null : position?.id ?? call.positionId,
318+
positionId: shouldRemovePosition ? null : (position?.id ?? call.positionId),
319319
descriptionData: data.descriptionData ?? undefined,
320320
situationCodeId: data.situationCode === null ? null : data.situationCode,
321321
typeId: data.type,

apps/api/src/controllers/leo/jail-controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { NotFound } from "@tsed/exceptions";
55
import { prisma } from "lib/data/prisma";
66
import { IsAuth } from "middlewares/auth/is-auth";
77
import { leoProperties } from "utils/leo/includes";
8-
8+
import type { z } from "zod";
99
import { type MiscCadSettings, ReleaseType, type Prisma, PublishStatus } from "@prisma/client";
1010
import { validateSchema } from "lib/data/validate-schema";
1111
import { RELEASE_CITIZEN_SCHEMA } from "@snailycad/schemas";
@@ -123,7 +123,7 @@ export class JailController {
123123

124124
private async handleReleaseCitizen(
125125
citizenId: string,
126-
data: Zod.infer<typeof RELEASE_CITIZEN_SCHEMA> & { force?: true },
126+
data: z.infer<typeof RELEASE_CITIZEN_SCHEMA> & { force?: true },
127127
) {
128128
const citizen = await prisma.citizen.findUnique({
129129
where: { id: citizenId },

apps/api/src/controllers/leo/search/NotesController.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { NotFound } from "@tsed/exceptions";
88
import { UsePermissions, Permissions } from "middlewares/use-permissions";
99
import type { Citizen, RegisteredVehicle } from "@prisma/client";
1010
import type * as APITypes from "@snailycad/types/api";
11+
import type { z } from "zod";
1112

1213
@Controller("/notes")
1314
@UseBeforeEach(IsAuth)
@@ -68,7 +69,7 @@ export class NotesController {
6869
return true;
6970
}
7071

71-
private getPrismaName(data: Zod.infer<typeof NOTE_SCHEMA>) {
72+
private getPrismaName(data: z.infer<typeof NOTE_SCHEMA>) {
7273
const prismaNames = {
7374
CITIZEN: "citizen",
7475
VEHICLE: "registeredVehicle",
@@ -78,9 +79,7 @@ export class NotesController {
7879
return name;
7980
}
8081

81-
private async findItem<T extends Citizen | RegisteredVehicle>(
82-
data: Zod.infer<typeof NOTE_SCHEMA>,
83-
) {
82+
private async findItem<T extends Citizen | RegisteredVehicle>(data: z.infer<typeof NOTE_SCHEMA>) {
8483
const name = this.getPrismaName(data);
8584
// @ts-expect-error methods have the same properties here.
8685
const item = await prisma[name].findUnique({

apps/api/src/controllers/record/records-controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export class RecordsController {
293293

294294
try {
295295
const args = process.env.IS_USING_ROOT_USER === "true" ? ["--no-sandbox"] : [];
296-
const browser = await puppeteer.launch({ args, headless: "new" });
296+
const browser = await puppeteer.launch({ args, headless: true });
297297
const page = await browser.newPage();
298298

299299
page.setContent(template, { waitUntil: "domcontentloaded" });
@@ -388,7 +388,7 @@ export class RecordsController {
388388

389389
try {
390390
const args = process.env.IS_USING_ROOT_USER === "true" ? ["--no-sandbox"] : [];
391-
const browser = await puppeteer.launch({ args, headless: "new" });
391+
const browser = await puppeteer.launch({ args, headless: true });
392392
const page = await browser.newPage();
393393

394394
page.setContent(template, { waitUntil: "domcontentloaded" });

0 commit comments

Comments
 (0)