Compare commits

...

2 commits

Author SHA1 Message Date
Joe Arndt
47e59c38e3 moved to forFeature/autoLoadEntities pattern 2026-02-09 15:06:48 -06:00
Joe Arndt
8e7016d15c migrated from sqlite to postgres 2026-02-09 14:51:27 -06:00
10 changed files with 365 additions and 73 deletions

View file

@ -7,27 +7,14 @@ $ npm install
``` ```
## Compile and run the project ## Compile and run the project
Run local Postgres DB:
```bash ```bash
# development docker run --name common-cents-db -e POSTGRES_USER=common-cents -e POSTGRES_PASSWORD=CommonCents_123! -p 5432:5432 -d postgres
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
``` ```
## Run tests Then run the API:
```bash ```bash
# unit tests npm run start:dev
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
``` ```
## Deployment ## Deployment

View file

@ -12,6 +12,6 @@ post {
body:json { body:json {
{ {
"name": "Category Three" "name": "First Cat"
} }
} }

358
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -25,9 +25,9 @@
"@nestjs/mapped-types": "*", "@nestjs/mapped-types": "*",
"@nestjs/platform-express": "^11.0.1", "@nestjs/platform-express": "^11.0.1",
"@nestjs/typeorm": "^11.0.0", "@nestjs/typeorm": "^11.0.0",
"pg": "^8.18.0",
"reflect-metadata": "^0.2.2", "reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1", "rxjs": "^7.8.1",
"sqlite3": "^5.1.7",
"typeorm": "^0.3.28" "typeorm": "^0.3.28"
}, },
"devDependencies": { "devDependencies": {

View file

@ -1,29 +1,24 @@
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { AppController } from './app.controller'; import { AppController } from './app.controller';
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm'; import { TypeOrmModule } from '@nestjs/typeorm';
import { MerchantsModule } from './merchants/merchants.module'; import { MerchantsModule } from './merchants/merchants.module';
import { Merchant } from './merchants/entities/merchant.entity';
import { TagsModule } from './tags/tags.module'; import { TagsModule } from './tags/tags.module';
import { Tag } from './tags/entities/tag.entity';
import { CategoriesModule } from './categories/categories.module'; import { CategoriesModule } from './categories/categories.module';
import { Category } from './categories/entities/category.entity';
import { SubCategoriesModule } from './sub-categories/sub-categories.module'; import { SubCategoriesModule } from './sub-categories/sub-categories.module';
import { SubCategory } from './sub-categories/entities/sub-category.entity';
import { ExpensesModule } from './expenses/expenses.module'; import { ExpensesModule } from './expenses/expenses.module';
import { Expense } from './expenses/entities/expense.entity';
const entities = [Merchant, Tag, Category, SubCategory, Expense];
const sqliteConfig: TypeOrmModuleOptions = {
synchronize: true,
type: 'sqlite',
database: 'common-cents.db',
entities
}
@Module({ @Module({
imports: [ imports: [
TypeOrmModule.forRoot(sqliteConfig), TypeOrmModule.forRoot({
synchronize: true,
type: 'postgres',
host: 'localhost',
port: 5432,
username: 'common-cents',
password: 'CommonCents_123!',
database: 'common-cents',
autoLoadEntities: true
}),
MerchantsModule, MerchantsModule,
TagsModule, TagsModule,
CategoriesModule, CategoriesModule,

View file

@ -2,9 +2,13 @@ import { Module } from '@nestjs/common';
import { CategoriesService } from './categories.service'; import { CategoriesService } from './categories.service';
import { CategoriesController } from './categories.controller'; import { CategoriesController } from './categories.controller';
import { CategoryDataService } from './category-data.service'; import { CategoryDataService } from './category-data.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Category } from './entities/category.entity';
@Module({ @Module({
controllers: [CategoriesController], controllers: [CategoriesController],
providers: [CategoriesService, CategoryDataService] providers: [CategoriesService, CategoryDataService],
imports: [TypeOrmModule.forFeature([Category])],
exports: [TypeOrmModule]
}) })
export class CategoriesModule { } export class CategoriesModule { }

View file

@ -2,9 +2,13 @@ import { Module } from '@nestjs/common';
import { ExpensesService } from './expenses.service'; import { ExpensesService } from './expenses.service';
import { ExpensesController } from './expenses.controller'; import { ExpensesController } from './expenses.controller';
import { ExpenseDataService } from './expense-data.service'; import { ExpenseDataService } from './expense-data.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Expense } from './entities/expense.entity';
@Module({ @Module({
controllers: [ExpensesController], controllers: [ExpensesController],
providers: [ExpensesService, ExpenseDataService], providers: [ExpensesService, ExpenseDataService],
imports: [TypeOrmModule.forFeature([Expense])],
exports: [TypeOrmModule]
}) })
export class ExpensesModule { } export class ExpensesModule { }

View file

@ -2,9 +2,13 @@ import { Module } from '@nestjs/common';
import { MerchantsService } from './merchants.service'; import { MerchantsService } from './merchants.service';
import { MerchantsController } from './merchants.controller'; import { MerchantsController } from './merchants.controller';
import { MerchantDataService } from './merchant-data.service'; import { MerchantDataService } from './merchant-data.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Merchant } from './entities/merchant.entity';
@Module({ @Module({
controllers: [MerchantsController], controllers: [MerchantsController],
providers: [MerchantsService, MerchantDataService] providers: [MerchantsService, MerchantDataService],
imports: [TypeOrmModule.forFeature([Merchant])],
exports: [TypeOrmModule]
}) })
export class MerchantsModule { } export class MerchantsModule { }

View file

@ -2,9 +2,13 @@ import { Module } from '@nestjs/common';
import { SubCategoriesService } from './sub-categories.service'; import { SubCategoriesService } from './sub-categories.service';
import { SubCategoriesController } from './sub-categories.controller'; import { SubCategoriesController } from './sub-categories.controller';
import { SubCategoryDataService } from './sub-category-data.service'; import { SubCategoryDataService } from './sub-category-data.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { SubCategory } from './entities/sub-category.entity';
@Module({ @Module({
controllers: [SubCategoriesController], controllers: [SubCategoriesController],
providers: [SubCategoriesService, SubCategoryDataService] providers: [SubCategoriesService, SubCategoryDataService],
imports: [TypeOrmModule.forFeature([SubCategory])],
exports: [TypeOrmModule]
}) })
export class SubCategoriesModule { } export class SubCategoriesModule { }

View file

@ -2,9 +2,13 @@ import { Module } from '@nestjs/common';
import { TagsService } from './tags.service'; import { TagsService } from './tags.service';
import { TagsController } from './tags.controller'; import { TagsController } from './tags.controller';
import { TagDataService } from './tag-data.service'; import { TagDataService } from './tag-data.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Tag } from './entities/tag.entity';
@Module({ @Module({
controllers: [TagsController], controllers: [TagsController],
providers: [TagsService, TagDataService] providers: [TagsService, TagDataService],
imports: [TypeOrmModule.forFeature([Tag])],
exports: [TypeOrmModule]
}) })
export class TagsModule { } export class TagsModule { }