Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm check
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"editor.defaultFormatter": "biomejs.biome"
},
"editor.formatOnSave": true,
"extensions.ignoreRecommendations": true
"extensions.ignoreRecommendations": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
}
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ A ledger application for managing bank account transactions, built with TypeScri
- [Jest](https://jestjs.io/) - Testing framework
- [Biome](https://biomejs.dev/) - Code formatter and linter
- [tsup](https://github.com/egoist/tsup) - TypeScript bundler
- [Husky](https://typicode.github.io/husky/) - Git hooks management
- [tsx](https://github.com/esbuild-kit/tsx) - TypeScript execution environment

## Available Scripts

Expand Down
52 changes: 40 additions & 12 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.0-beta.1/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"ignore": [
"node_modules",
"dist",
"build",
"coverage",
".git",
".vscode",
".dockerignore"
"includes": [
"**",
"!**/node_modules",
"!**/dist",
"!**/build",
"!**/coverage",
"!**/.git",
"!**/.vscode",
"!**/.dockerignore"
]
},
"formatter": {
Expand All @@ -23,13 +24,40 @@
"indentWidth": 2,
"lineEnding": "lf"
},
"organizeImports": {
"enabled": false
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"style": {
"useLiteralEnumMembers": "error",
"noCommaOperator": "error",
"useNodejsImportProtocol": "error",
"useAsConstAssertion": "error",
"useNumericLiterals": "error",
"useEnumInitializers": "error",
"useSelfClosingElements": "error",
"useConst": "error",
"useSingleVarDeclarator": "error",
"noUnusedTemplateLiteral": "error",
"useNumberNamespace": "error",
"noInferrableTypes": "error",
"useExponentiationOperator": "error",
"useTemplate": "error",
"noParameterAssign": "error",
"noNonNullAssertion": "error",
"useDefaultParameterLast": "error",
"noArguments": "error",
"useImportType": "error",
"useExportType": "error",
"noUselessElse": "error",
"useShorthandFunctionType": "error"
},
"correctness": {
"noUnusedImports": "error",
"noUnusedVariables": "error",
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"build": "tsup",
"dev": "tsx src/index.ts",
"watch": "tsx watch --exclude src/**/*.test.ts src/ src/index.ts",
"seed": "tsx src/seeds/seed.ts"
"seed": "tsx src/seeds/seed.ts",
"prepare": "husky"
},
"keywords": [
"botkeeper"
Expand All @@ -29,14 +30,15 @@
"zod": "^3.24.2"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@biomejs/biome": "2.0.0-beta.1",
"@swc/core": "^1.11.16",
"@swc/jest": "^0.2.37",
"@types/express": "^5.0.1",
"@types/jest": "^29.5.14",
"@types/supertest": "^6.0.3",
"@types/swagger-ui-express": "^4.1.8",
"dotenv": "^16.4.7",
"husky": "^9.1.7",
"jest": "^29.7.0",
"mongodb-memory-server": "^10.1.4",
"supertest": "^7.1.0",
Expand Down
86 changes: 48 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import express from 'express';
import apiRoutes from '@/routes';
import errorHandler from '@/middleware/errorHandler';
import swaggerUi from 'swagger-ui-express';
import errorHandler from '@/middleware/errorHandler';
import apiRoutes from '@/routes';
import swaggerDocument from './../swagger.json';

const app = express();
Expand Down
2 changes: 1 addition & 1 deletion src/config/environment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import dotenv from 'dotenv';
import { z } from 'zod';

dotenv.config();

Expand Down
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import mongoose from 'mongoose';

import loadEnvironment from '@/config/environment';
import { connectDB } from '@/config/database';
import loadEnvironment from '@/config/environment';

import app from './app';

Expand Down
4 changes: 2 additions & 2 deletions src/middleware/errorHandler.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Request, Response, NextFunction } from 'express';
import errorHandler from './errorHandler';
import type { NextFunction, Request, Response } from 'express';
import { StatusCodes } from 'http-status-codes';
import errorHandler from './errorHandler';

describe('Error Handler Middleware', () => {
let mockRequest: Partial<Request>;
Expand Down
4 changes: 2 additions & 2 deletions src/middleware/schemaValidator.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Request, Response, NextFunction } from 'express';
import { z } from 'zod';
import type { NextFunction, Request, Response } from 'express';
import { StatusCodes } from 'http-status-codes';
import { z } from 'zod';
import schemaValidator from './schemaValidator';

describe('Schema Validator Middleware', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/middleware/schemaValidator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Request, Response, NextFunction } from 'express';
import { type z, ZodError } from 'zod';
import type { NextFunction, Request, Response } from 'express';
import { StatusCodes } from 'http-status-codes';
import { ZodError, type z } from 'zod';

type ValidationSchema = {
body?: z.ZodType;
Expand Down
2 changes: 1 addition & 1 deletion src/models/Account.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import mongoose from 'mongoose';
import { MongoMemoryServer } from 'mongodb-memory-server';
import mongoose from 'mongoose';
import { Account } from './Account';

describe('Account Model', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/models/Transaction.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mongoose from 'mongoose';
import { MongoMemoryServer } from 'mongodb-memory-server';
import { Transaction, TransactionType } from './Transaction';
import mongoose from 'mongoose';
import { Account, type IAccount } from './Account';
import { Transaction, TransactionType } from './Transaction';

describe('Transaction Model', () => {
let mongoServer: MongoMemoryServer;
Expand Down
2 changes: 1 addition & 1 deletion src/routes/account/create/controller.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Request, Response } from 'express';
import createAccountController from './controller';
import { Account } from '@/models/Account';
import createAccountController from './controller';

describe('createAccountController', () => {
let req: Partial<Request>;
Expand Down
2 changes: 1 addition & 1 deletion src/routes/account/create/controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Request, Response } from 'express';
import { Account } from '@/models/Account';
import { StatusCodes } from 'http-status-codes';
import { Account } from '@/models/Account';

export default async (req: Request, res: Response) => {
const account = await Account.create(req.body);
Expand Down
2 changes: 1 addition & 1 deletion src/routes/account/create/schema.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import schema from './schema';
import { z } from 'zod';
import schema from './schema';

describe('Account create schema', () => {
it('should succeed with valid data', () => {
Expand Down
Loading