feat: added biome on pre-commit

This commit is contained in:
Hackntosh 2024-02-03 14:41:32 +00:00
parent 6f7aafef81
commit 66681673bc
41 changed files with 2530 additions and 772 deletions

View file

@ -1,5 +1,5 @@
if (process.env.NODE_ENV === 'production' || process.env.CI === 'true') {
process.exit(0)
if (process.env.NODE_ENV === "production" || process.env.CI === "true") {
process.exit(0);
}
const husky = (await import('husky')).default
console.log(husky())
const husky = (await import("husky")).default;
console.log(husky());

1
.husky/pre-commit Normal file
View file

@ -0,0 +1 @@
lint-staged

View file

@ -1,5 +1,3 @@
{
"recommendations": [
"biomejs.biome"
]
"recommendations": ["biomejs.biome"]
}

View file

@ -1,3 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
extends: ["@commitlint/config-conventional"],
};

1753
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -61,6 +61,8 @@
},
"devDependencies": {
"@biomejs/biome": "1.5.3",
"@commitlint/cli": "^18.6.0",
"@commitlint/config-conventional": "^18.6.0",
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.0.0",
@ -81,6 +83,7 @@
"eslint-plugin-prettier": "^5.0.0",
"husky": "^9.0.7",
"jest": "^29.5.0",
"lint-staged": "^15.2.1",
"prettier": "^3.0.0",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
@ -108,5 +111,8 @@
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
},
"lint-staged": {
"**.{js|ts|json}": "biome check --apply --no-errors-on-unmatched"
}
}

View file

@ -1,15 +1,15 @@
import { FastifyMulterModule } from "@nest-lab/fastify-multer";
import { Module } from "@nestjs/common";
import { UserModule } from "./users/users.module";
import { ConfigModule } from "@nestjs/config";
import { APP_GUARD, APP_PIPE } from "@nestjs/core";
import { ThrottlerGuard, ThrottlerModule } from "@nestjs/throttler";
import { S3Module } from "nestjs-s3";
import { ThrottlerStorageRedisService } from "nestjs-throttler-storage-redis";
import { ZodValidationPipe } from "nestjs-zod";
import { AuthModule } from "./auth/auth.module";
import { ConfigModule } from "@nestjs/config";
import { JwtAuthGuard } from "./auth/jwt-auth.guard";
import { ThrottlerGuard, ThrottlerModule } from "@nestjs/throttler";
import { ThrottlerStorageRedisService } from "nestjs-throttler-storage-redis";
import { KweeksModule } from "./kweeks/kweeks.module";
import { FastifyMulterModule } from "@nest-lab/fastify-multer";
import { S3Module } from "nestjs-s3";
import { UserModule } from "./users/users.module";
@Module({
imports: [

View file

@ -1,10 +1,10 @@
import {
Controller,
Request,
Post,
UseGuards,
Body,
Controller,
HttpCode,
Post,
Request,
UseGuards,
} from "@nestjs/common";
import {
ApiOkResponse,
@ -12,10 +12,10 @@ import {
ApiTags,
ApiUnauthorizedResponse,
} from "@nestjs/swagger";
import { LocalAuthGuard } from "./local-auth.guard";
import { Public } from "src/public.decorator";
import { AuthService } from "./auth.service";
import { LoginUserDTO } from "./dto/login.dto";
import { Public } from "src/public.decorator";
import { LocalAuthGuard } from "./local-auth.guard";
@ApiTags("Auth")
@Controller("auth")

View file

@ -1,11 +1,11 @@
import { Module } from "@nestjs/common";
import { AuthService } from "./auth.service";
import { JwtModule } from "@nestjs/jwt";
import { PassportModule } from "@nestjs/passport";
import { LocalStrategy } from "./local.strategy";
import { UserModule } from "src/users/users.module";
import { AuthController } from "./auth.controller";
import { JwtModule } from "@nestjs/jwt";
import { AuthService } from "./auth.service";
import { JwtStrategy } from "./jwt.strategy";
import { LocalStrategy } from "./local.strategy";
@Module({
controllers: [AuthController],

View file

@ -1,8 +1,8 @@
import { Injectable } from "@nestjs/common";
import { UserService } from "src/users/users.service";
import { JwtService } from "@nestjs/jwt";
import * as bcrypt from "bcrypt";
import { UserModel } from "src/users/models/user.model";
import { JwtService } from "@nestjs/jwt";
import { UserService } from "src/users/users.service";
@Injectable()
export class AuthService {

View file

@ -1,8 +1,8 @@
import { Injectable, UnauthorizedException } from "@nestjs/common";
import { PassportStrategy } from "@nestjs/passport";
import { Strategy } from "passport-local";
import { AuthService } from "./auth.service";
import { UserModel } from "src/users/models/user.model";
import { AuthService } from "./auth.service";
@Injectable()
export class LocalStrategy extends PassportStrategy(Strategy) {

View file

@ -1,4 +1,4 @@
import { PartialType } from '@nestjs/swagger';
import { CreateKweekDto } from './create-kweek.dto';
import { PartialType } from "@nestjs/swagger";
import { CreateKweekDto } from "./create-kweek.dto";
export class UpdateKweekDto extends PartialType(CreateKweekDto) {}

View file

@ -1,7 +1,7 @@
import { Module } from "@nestjs/common";
import { KweeksService } from "./kweeks.service";
import { KweeksController } from "./kweeks.controller";
import { PrismaModule } from "src/prisma/prisma.module";
import { KweeksController } from "./kweeks.controller";
import { KweeksService } from "./kweeks.service";
@Module({
imports: [PrismaModule],

View file

@ -1,7 +1,7 @@
import { Injectable } from "@nestjs/common";
import { PrismaService } from "src/prisma/prisma.service";
import { CreateKweekDTO } from "./dto/create-kweek.dto";
import { UpdateKweekDto } from "./dto/update-kweek.dto";
import { PrismaService } from "src/prisma/prisma.service";
@Injectable()
export class KweeksService {

View file

@ -1,12 +1,12 @@
import * as helmet from "@fastify/helmet";
import { NestFactory } from "@nestjs/core";
import { SwaggerModule, DocumentBuilder } from "@nestjs/swagger";
import { AppModule } from "./app.module";
import { patchNestJsSwagger } from "nestjs-zod";
import {
FastifyAdapter,
NestFastifyApplication,
} from "@nestjs/platform-fastify";
import * as helmet from "@fastify/helmet";
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
import { patchNestJsSwagger } from "nestjs-zod";
import { AppModule } from "./app.module";
// TODO: File Upload (Posts and User Profile Image)

View file

@ -1,3 +1,4 @@
import { File, FileInterceptor } from "@nest-lab/fastify-multer";
import {
Body,
Controller,
@ -22,17 +23,16 @@ import {
ApiTags,
ApiUnauthorizedResponse,
} from "@nestjs/swagger";
import { UserService } from "./users.service";
import { CreateUserDTO } from "./dto/create-user.dto";
import { Public } from "src/public.decorator";
import { UpdateNameDTO } from "./dto/update-name.dto";
import { User } from "./types/user.type";
import { UpdateEmailDTO } from "./dto/update-email.dto";
import { UpdatePasswordDTO } from "./dto/update-password.dto";
import { File, FileInterceptor } from "@nest-lab/fastify-multer";
import { BufferValidator } from "src/validators/buffer-validator.pipe";
import UploadImageSchema from "./schemas/upload-image.schema";
import UploadImageValidator from "src/validators/upload-image.validator";
import { CreateUserDTO } from "./dto/create-user.dto";
import { UpdateEmailDTO } from "./dto/update-email.dto";
import { UpdateNameDTO } from "./dto/update-name.dto";
import { UpdatePasswordDTO } from "./dto/update-password.dto";
import UploadImageSchema from "./schemas/upload-image.schema";
import { User } from "./types/user.type";
import { UserService } from "./users.service";
@ApiTags("Users")
@Controller("users")

View file

@ -1,8 +1,8 @@
import { Module } from "@nestjs/common";
import { UserController } from "./users.controller";
import { UserService } from "./users.service";
import { PrismaModule } from "src/prisma/prisma.module";
import { S3Service } from "./s3.service";
import { UserController } from "./users.controller";
import { UserService } from "./users.service";
@Module({
imports: [PrismaModule],

View file

@ -1,15 +1,15 @@
import { File } from "@nest-lab/fastify-multer";
import {
BadRequestException,
Injectable,
NotFoundException,
} from "@nestjs/common";
import { CreateUserDTO } from "./dto/create-user.dto";
import { PrismaService } from "src/prisma/prisma.service";
import { UserModel } from "./models/user.model";
import * as bcrypt from "bcrypt";
import { User } from "./types/user.type";
import { File } from "@nest-lab/fastify-multer";
import { PrismaService } from "src/prisma/prisma.service";
import { CreateUserDTO } from "./dto/create-user.dto";
import { UserModel } from "./models/user.model";
import { S3Service } from "./s3.service";
import { User } from "./types/user.type";
@Injectable()
export class UserService {

View file

@ -1,9 +1,9 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from './../src/app.module';
import { INestApplication } from "@nestjs/common";
import { Test, TestingModule } from "@nestjs/testing";
import * as request from "supertest";
import { AppModule } from "./../src/app.module";
describe('AppController (e2e)', () => {
describe("AppController (e2e)", () => {
let app: INestApplication;
beforeEach(async () => {
@ -15,10 +15,10 @@ describe('AppController (e2e)', () => {
await app.init();
});
it('/ (GET)', () => {
it("/ (GET)", () => {
return request(app.getHttpServer())
.get('/')
.get("/")
.expect(200)
.expect('Hello World!');
.expect("Hello World!");
});
});