Compare commits

...

2 commits

Author SHA1 Message Date
612ef52d01
remove swc from build
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 1m7s
2025-02-14 17:50:11 +01:00
b73477e082
build prod swagger types 2025-02-14 17:14:07 +01:00
7 changed files with 48 additions and 35 deletions

View file

@ -275,27 +275,27 @@
"@swc/cli": ["@swc/cli@0.6.0", "", { "dependencies": { "@swc/counter": "^0.1.3", "@xhmikosr/bin-wrapper": "^13.0.5", "commander": "^8.3.0", "fast-glob": "^3.2.5", "minimatch": "^9.0.3", "piscina": "^4.3.1", "semver": "^7.3.8", "slash": "3.0.0", "source-map": "^0.7.3" }, "peerDependencies": { "@swc/core": "^1.2.66", "chokidar": "^4.0.1" }, "optionalPeers": ["chokidar"], "bin": { "swc": "bin/swc.js", "swcx": "bin/swcx.js", "spack": "bin/spack.js" } }, "sha512-Q5FsI3Cw0fGMXhmsg7c08i4EmXCrcl+WnAxb6LYOLHw4JFFC3yzmx9LaXZ7QMbA+JZXbigU2TirI7RAfO0Qlnw=="], "@swc/cli": ["@swc/cli@0.6.0", "", { "dependencies": { "@swc/counter": "^0.1.3", "@xhmikosr/bin-wrapper": "^13.0.5", "commander": "^8.3.0", "fast-glob": "^3.2.5", "minimatch": "^9.0.3", "piscina": "^4.3.1", "semver": "^7.3.8", "slash": "3.0.0", "source-map": "^0.7.3" }, "peerDependencies": { "@swc/core": "^1.2.66", "chokidar": "^4.0.1" }, "optionalPeers": ["chokidar"], "bin": { "swc": "bin/swc.js", "swcx": "bin/swcx.js", "spack": "bin/spack.js" } }, "sha512-Q5FsI3Cw0fGMXhmsg7c08i4EmXCrcl+WnAxb6LYOLHw4JFFC3yzmx9LaXZ7QMbA+JZXbigU2TirI7RAfO0Qlnw=="],
"@swc/core": ["@swc/core@1.10.9", "", { "dependencies": { "@swc/counter": "^0.1.3", "@swc/types": "^0.1.17" }, "optionalDependencies": { "@swc/core-darwin-arm64": "1.10.9", "@swc/core-darwin-x64": "1.10.9", "@swc/core-linux-arm-gnueabihf": "1.10.9", "@swc/core-linux-arm64-gnu": "1.10.9", "@swc/core-linux-arm64-musl": "1.10.9", "@swc/core-linux-x64-gnu": "1.10.9", "@swc/core-linux-x64-musl": "1.10.9", "@swc/core-win32-arm64-msvc": "1.10.9", "@swc/core-win32-ia32-msvc": "1.10.9", "@swc/core-win32-x64-msvc": "1.10.9" }, "peerDependencies": { "@swc/helpers": "*" }, "optionalPeers": ["@swc/helpers"] }, "sha512-MQ97YSXu2oibzm7wi4GNa7hhndjLuVt/lmO2sq53+P37oZmyg/JQ/IYYtSiC6UGK3+cHoiVAykrK+glxLjJbag=="], "@swc/core": ["@swc/core@1.10.16", "", { "dependencies": { "@swc/counter": "^0.1.3", "@swc/types": "^0.1.17" }, "optionalDependencies": { "@swc/core-darwin-arm64": "1.10.16", "@swc/core-darwin-x64": "1.10.16", "@swc/core-linux-arm-gnueabihf": "1.10.16", "@swc/core-linux-arm64-gnu": "1.10.16", "@swc/core-linux-arm64-musl": "1.10.16", "@swc/core-linux-x64-gnu": "1.10.16", "@swc/core-linux-x64-musl": "1.10.16", "@swc/core-win32-arm64-msvc": "1.10.16", "@swc/core-win32-ia32-msvc": "1.10.16", "@swc/core-win32-x64-msvc": "1.10.16" }, "peerDependencies": { "@swc/helpers": "*" }, "optionalPeers": ["@swc/helpers"] }, "sha512-nOINg/OUcZazCW7B55QV2/UB8QAqz9FYe4+z229+4RYboBTZ102K7ebOEjY5sKn59JgAkhjZTz+5BKmXpDFopw=="],
"@swc/core-darwin-arm64": ["@swc/core-darwin-arm64@1.10.9", "", { "os": "darwin", "cpu": "arm64" }, "sha512-XTHLtijFervv2B+i1ngM993umhSj9K1IeMomvU/Db84Asjur2XmD4KXt9QPnGDRFgv2kLSjZ+DDL25Qk0f4r+w=="], "@swc/core-darwin-arm64": ["@swc/core-darwin-arm64@1.10.16", "", { "os": "darwin", "cpu": "arm64" }, "sha512-iikIxwqCQ4Bvz79vJ4ELh26efPf1u5D9TFdmXSJUBs7C3mmMHvk5zyWD9A9cTowXiW6WHs2gE58U1R9HOTTIcg=="],
"@swc/core-darwin-x64": ["@swc/core-darwin-x64@1.10.9", "", { "os": "darwin", "cpu": "x64" }, "sha512-bi3el9/FV/la8HIsolSjeDar+tM7m9AmSF1w7X6ZByW2qgc4Z1tmq0A4M4H9aH3TfHesZbfq8hgaNtc2/VtzzQ=="], "@swc/core-darwin-x64": ["@swc/core-darwin-x64@1.10.16", "", { "os": "darwin", "cpu": "x64" }, "sha512-R2Eb9aktWd62vPfW9H/c/OaQ0e94iURibBo4uzUUcgxNNmB4+wb6piKbHxGdr/5bEsT+vJ1lwZFSRzfb45E7DA=="],
"@swc/core-linux-arm-gnueabihf": ["@swc/core-linux-arm-gnueabihf@1.10.9", "", { "os": "linux", "cpu": "arm" }, "sha512-xsLHV02S+RTDuI+UJBkA2muNk/s0ETRpoc1K/gNt0i8BqTurPYkrvGDDALN9+leiUPydHvZi9P1qdExbgUJnXw=="], "@swc/core-linux-arm-gnueabihf": ["@swc/core-linux-arm-gnueabihf@1.10.16", "", { "os": "linux", "cpu": "arm" }, "sha512-mkqN3HBAMnuiSGZ/k2utScuH8rAPshvNj0T1LjBWon+X9DkMNHSA+aMLdWsy0yZKF1zjOPc4L3Uq2l2wzhUlzA=="],
"@swc/core-linux-arm64-gnu": ["@swc/core-linux-arm64-gnu@1.10.9", "", { "os": "linux", "cpu": "arm64" }, "sha512-41hJgPoGhIa12U6Tud+yLF/m64YA3mGut3TmBEkj2R7rdJdE0mljdtR0tf4J2RoQaWZPPi0DBSqGdROiAEx9dg=="], "@swc/core-linux-arm64-gnu": ["@swc/core-linux-arm64-gnu@1.10.16", "", { "os": "linux", "cpu": "arm64" }, "sha512-PH/+q/L5nVZJ91CU07CL6Q9Whs6iR6nneMZMAgtVF9Ix8ST0cWVItdUhs6D38kFklCFhaOrpHhS01HlMJ72vWw=="],
"@swc/core-linux-arm64-musl": ["@swc/core-linux-arm64-musl@1.10.9", "", { "os": "linux", "cpu": "arm64" }, "sha512-DUMRhl49b9r7bLg9oNzCdW4lLcDJKrRBn87Iq5APPvixsm1auGnsVQycGkQcDDKvVllxIFSbmCYzjagx3l8Hnw=="], "@swc/core-linux-arm64-musl": ["@swc/core-linux-arm64-musl@1.10.16", "", { "os": "linux", "cpu": "arm64" }, "sha512-1169+C9XbydKKc6Ec1XZxTGKtHjZHDIFn0r+Nqp/QSVwkORrOY1Vz2Hdu7tn/lWMg36ZkGePS+LnnyV67s/7yg=="],
"@swc/core-linux-x64-gnu": ["@swc/core-linux-x64-gnu@1.10.9", "", { "os": "linux", "cpu": "x64" }, "sha512-xW0y88vQvmzYo3Gn7yFnY03TfHMwuca4aFH3ZmhwDNOYHmTOi6fmhAkg/13F/NrwjMYO+GnF5uJTjdjb3B6tdQ=="], "@swc/core-linux-x64-gnu": ["@swc/core-linux-x64-gnu@1.10.16", "", { "os": "linux", "cpu": "x64" }, "sha512-n2rV0XwkjoHn4MDJmpYp5RBrnyi94/6GsJVpbn6f+/eqSrZn3mh3dT7pdZc9zCN1Qp9eDHo+uI6e/wgvbL22uA=="],
"@swc/core-linux-x64-musl": ["@swc/core-linux-x64-musl@1.10.9", "", { "os": "linux", "cpu": "x64" }, "sha512-jYs32BEx+CPVuxN6NdsWEpdehjnmAag25jyJzwjQx+NCGYwHEV3bT5y8TX4eFhaVB1rafmqJOlYQPs4+MSyGCg=="], "@swc/core-linux-x64-musl": ["@swc/core-linux-x64-musl@1.10.16", "", { "os": "linux", "cpu": "x64" }, "sha512-EevCpwreBrkPrJjQVIbiM81lK42ukNNSlBmrSRxxbx2V9VGmOd5qxX0cJBn0TRRSLIPi62BuMS76F9iYjqsjgg=="],
"@swc/core-win32-arm64-msvc": ["@swc/core-win32-arm64-msvc@1.10.9", "", { "os": "win32", "cpu": "arm64" }, "sha512-Uhh5T3Fq3Nyom96Bm3ACBNASH3iqNc76in7ewZz8PooUqeTIO8aZpsghnncjctRNE9T819/8btpiFIhHo3sKtg=="], "@swc/core-win32-arm64-msvc": ["@swc/core-win32-arm64-msvc@1.10.16", "", { "os": "win32", "cpu": "arm64" }, "sha512-BvE7RWAnKJeELVQWLok6env5I4GUVBTZSvaSN/VPgxnTjF+4PsTeQptYx0xCYhp5QCv68wWYsBnZKuPDS+SBsw=="],
"@swc/core-win32-ia32-msvc": ["@swc/core-win32-ia32-msvc@1.10.9", "", { "os": "win32", "cpu": "ia32" }, "sha512-bD5BpbojEsDfrAvT+1qjQPf5RCKLg4UL+3Uwm019+ZR02hd8qO538BlOnQdOqRqccu+75DF6aRglQ7AJ24Cs0Q=="], "@swc/core-win32-ia32-msvc": ["@swc/core-win32-ia32-msvc@1.10.16", "", { "os": "win32", "cpu": "ia32" }, "sha512-7Jf/7AeCgbLR/JsQgMJuacHIq4Jeie3knf6+mXxn8aCvRypsOTIEu0eh7j24SolOboxK1ijqJ86GyN1VA2Rebg=="],
"@swc/core-win32-x64-msvc": ["@swc/core-win32-x64-msvc@1.10.9", "", { "os": "win32", "cpu": "x64" }, "sha512-NwkuUNeBBQnAaXVvcGw8Zr6RR8kylyjFUnlYZZ3G0QkQZ4rYLXYTafAmiRjrfzgVb0LcMF/sBzJvGOk7SwtIDg=="], "@swc/core-win32-x64-msvc": ["@swc/core-win32-x64-msvc@1.10.16", "", { "os": "win32", "cpu": "x64" }, "sha512-p0blVm0R8bjaTtmW+FoPmLxLSQdRNbqhuWcR/8g80OzMSkka9mk5/J3kn/5JRVWh+MaR9LHRHZc1Q1L8zan13g=="],
"@swc/counter": ["@swc/counter@0.1.3", "", {}, "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ=="], "@swc/counter": ["@swc/counter@0.1.3", "", {}, "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ=="],

View file

@ -1,16 +1,24 @@
{ {
"$schema": "https://json.schemastore.org/nest-cli", "$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics", "collection": "@nestjs/schematics",
"sourceRoot": "src", "sourceRoot": "src",
"entryFile": "app", "entryFile": "app",
"compilerOptions": { "compilerOptions": {
"deleteOutDir": true, "deleteOutDir": true,
"plugins": [{ "plugins": [
"name": "@nestjs/swagger", {
"options": { "name": "@nestjs/swagger",
"dtoFileNameSuffix": [".dto.ts", ".entity.ts", ".response.ts", ".payload.ts"], "options": {
"introspectComments": true "debug": true,
} "dtoFileNameSuffix": [
}] ".dto.ts",
} ".entity.ts",
".response.ts",
".payload.ts"
],
"introspectComments": true
}
}
]
}
} }

View file

@ -6,7 +6,7 @@
"private": true, "private": true,
"license": "UNLICENSED", "license": "UNLICENSED",
"scripts": { "scripts": {
"build": "bun build.ts", "build": "nest build",
"start": "bun --bun nest start", "start": "bun --bun nest start",
"start:dev": "bun --hot ./src/app.ts", "start:dev": "bun --hot ./src/app.ts",
"start:prod": "bun dist/app", "start:prod": "bun dist/app",
@ -48,6 +48,8 @@
"devDependencies": { "devDependencies": {
"@nestjs/cli": "^11.0.2", "@nestjs/cli": "^11.0.2",
"@stylistic/eslint-plugin": "^3.0.1", "@stylistic/eslint-plugin": "^3.0.1",
"@swc/cli": "^0.6.0",
"@swc/core": "^1.10.16",
"@types/bun": "^1.2.2", "@types/bun": "^1.2.2",
"@types/nodemailer": "^6.4.17", "@types/nodemailer": "^6.4.17",
"@types/passport-jwt": "^4.0.1", "@types/passport-jwt": "^4.0.1",

View file

@ -24,8 +24,9 @@ import KeyvRedis from '@keyv/redis';
ScheduleModule.forRoot(), ScheduleModule.forRoot(),
CacheModule.registerAsync({ CacheModule.registerAsync({
isGlobal: true, isGlobal: true,
// this Promise<any> is really nasty i don't like it at all
// eslint-disable-next-line @typescript-eslint/require-await // eslint-disable-next-line @typescript-eslint/require-await
useFactory: async () => { useFactory: async (): Promise<any> => {
return { return {
stores: [ stores: [
process.env.REDIS_URL process.env.REDIS_URL

View file

@ -15,6 +15,7 @@ import { ConsoleLogger, Logger } from '@nestjs/common';
import * as process from 'process'; import * as process from 'process';
import { FastifyReply } from 'fastify/types/reply'; import { FastifyReply } from 'fastify/types/reply';
import { FastifyRequest } from 'fastify/types/request'; import { FastifyRequest } from 'fastify/types/request';
import metadata from './metadata';
const logger: Logger = new Logger('App'); const logger: Logger = new Logger('App');

9
src/metadata.ts Normal file
View file

@ -0,0 +1,9 @@
/* eslint-disable */
export default async () => {
const t = {
["./common/modules/auth/models/entities/user.entity"]: await import("./common/modules/auth/models/entities/user.entity"),
["./common/models/entities/version.entity"]: await import("./common/models/entities/version.entity"),
["./common/modules/auth/models/payloads/login.payload"]: await import("./common/modules/auth/models/payloads/login.payload")
};
return { "@nestjs/swagger": { "models": [[import("./common/models/entities/version.entity"), { "VersionEntity": { version: { required: true, type: () => String } } }], [import("./common/modules/auth/models/dto/register.dto"), { "RegisterDto": { email: { required: true, type: () => String }, username: { required: true, type: () => String }, password: { required: true, type: () => String } } }], [import("./common/modules/auth/models/entities/user.entity"), { "UserEntity": { id: { required: true, type: () => String }, email: { required: true, type: () => String }, username: { required: true, type: () => String }, createdAt: { required: true, type: () => Date }, updatedAt: { required: true, type: () => Date }, verified: { required: true, type: () => Boolean }, password: { required: true, type: () => String }, tokenId: { required: true, type: () => String } } }], [import("./common/modules/auth/models/payloads/login.payload"), { "LoginPayload": { user: { required: true, type: () => t["./common/modules/auth/models/entities/user.entity"].UserEntity }, token: { required: true, type: () => String } } }], [import("./common/modules/auth/models/dto/local-login.dto"), { "LocalLoginDto": { email: { required: true, type: () => String }, password: { required: true, type: () => String } } }], [import("./common/models/dto/pagination.dto"), { "PaginationDto": { take: { required: false, type: () => Number, minimum: 1 }, skip: { required: false, type: () => Number, minimum: 0 } } }], [import("./common/models/responses/pagination.response"), { "PaginationResponse": { data: { required: true }, total: { required: true, type: () => Number }, take: { required: true, type: () => Number }, skip: { required: true, type: () => Number } } }]], "controllers": [[import("./app.controller"), { "AppController": { "getVersion": { type: t["./common/models/entities/version.entity"].VersionEntity } } }], [import("./common/modules/auth/register.controller"), { "RegisterController": { "register": { status: 500, description: "Internal server error" } } }], [import("./common/modules/auth/login.controller"), { "LoginController": { "login": { status: 500, description: "Internal server error", type: t["./common/modules/auth/models/payloads/login.payload"].LoginPayload }, "loginCallback": { status: 500, description: "Internal server error", type: t["./common/modules/auth/models/payloads/login.payload"].LoginPayload } } }], [import("./common/modules/auth/auth.controller"), { "AuthController": { "logoutAll": {} } }], [import("./modules/users/users.controller"), { "UsersController": { "getMyself": { type: t["./common/modules/auth/models/entities/user.entity"].UserEntity } } }]] } };
};

View file

@ -11,16 +11,12 @@ export class UsersService {
where: { where: {
id, id,
}, },
include: {
email_verifications: true,
},
}); });
if (!user) throw new NotFoundException('User not found'); if (!user) throw new NotFoundException('User not found');
return new UserEntity({ return new UserEntity({
id: user.id, id: user.id,
username: user.username, username: user.username,
email: user.email, email: user.email,
verified: !user.email_verifications,
password: user.password, password: user.password,
tokenId: user.token_id, tokenId: user.token_id,
createdAt: user.created_at, createdAt: user.created_at,
@ -33,16 +29,12 @@ export class UsersService {
where: { where: {
email, email,
}, },
include: {
email_verifications: true,
},
}); });
if (!user) throw new NotFoundException('User not found'); if (!user) throw new NotFoundException('User not found');
return new UserEntity({ return new UserEntity({
id: user.id, id: user.id,
username: user.username, username: user.username,
email: user.email, email: user.email,
verified: !user.email_verifications,
password: user.password, password: user.password,
tokenId: user.token_id, tokenId: user.token_id,
createdAt: user.created_at, createdAt: user.created_at,