This commit is contained in:
pwn
2025-12-05 11:14:59 +03:00
parent 376d0fc8ad
commit b79ef3a3f3
8 changed files with 35 additions and 18 deletions

View File

@@ -9,7 +9,7 @@ import { Project, ProjectSchema } from "./schemas/project.schema.js";
import { Function, FunctionSchema } from "./schemas/function.schema.js";
import { JwtModule } from "@nestjs/jwt";
import { BcryptService } from "./services/bcrypt.service.js";
import { JWT_SECRET } from "./auth/const.js";
import { JWT_SECRET, MONGO_URL } from "./auth/const.js";
import { AuthController } from "./controllers/auth.controller.js";
import { JwtStrategy } from "./auth/jwt.strategy.js";
import { LocalStrategy } from "./auth/local.strategy.js";
@@ -33,9 +33,7 @@ import { HealthController } from "./controllers/health.controller.js";
secret: JWT_SECRET,
signOptions: { expiresIn: "3600s" },
}),
MongooseModule.forRoot(
process.env.MONGO_URL ?? "mongodb://sigma:supersecret@localhost:27017"
),
MongooseModule.forRoot(MONGO_URL),
MongooseModule.forFeature([
{
name: User.name,

View File

@@ -1 +1,11 @@
export const JWT_SECRET = process.env["JWT_SECRET"] ?? "supersecret";
function getRequiredEnv(name: string): string {
const value = process.env[name];
if (!value) {
throw new Error(`${name} environment variable must be set`);
}
return value;
}
export const JWT_SECRET = getRequiredEnv("JWT_SECRET");
export const MONGO_URL = getRequiredEnv("MONGO_URL");

View File

@@ -86,7 +86,7 @@ export class FunctionsService {
});
if (func) {
await this.projectModel.findByIdAndUpdate(func._id, {
await this.projectModel.findByIdAndUpdate(func.project, {
$inc: {
functionsInvocationCount: 1,
functionsErrorCount: successful ? 0 : 1,

View File

@@ -15,7 +15,9 @@ async function bootstrap() {
app.set("query parser", "extended");
app.useGlobalPipes(
new ValidationPipe({
whitelist: false,
whitelist: true,
forbidNonWhitelisted: true,
transform: true,
})
);