Skip to content

Commit

Permalink
nx is coming back.
Browse files Browse the repository at this point in the history
  • Loading branch information
snurby7 committed Apr 15, 2021
1 parent 58a1af2 commit a317e35
Show file tree
Hide file tree
Showing 69 changed files with 1,704 additions and 172 deletions.
21 changes: 21 additions & 0 deletions apps/api/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"parserOptions": {
"project": ["apps/api/tsconfig.*?.json"]
},
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
14 changes: 14 additions & 0 deletions apps/api/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
displayName: 'api',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
},
},
transform: {
'^.+\\.[tj]s$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/apps/api',
};
Empty file added apps/api/src/app/.gitkeep
Empty file.
22 changes: 22 additions & 0 deletions apps/api/src/app/app.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Test, TestingModule } from '@nestjs/testing';

import { AppController } from './app.controller';
import { AppService } from './app.service';

describe('AppController', () => {
let app: TestingModule;

beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
});

describe('getData', () => {
it('should return "Welcome to api!"', () => {
const appController = app.get<AppController>(AppController);
expect(appController.getData()).toEqual({ message: 'Welcome to api!' });
});
});
});
13 changes: 13 additions & 0 deletions apps/api/src/app/app.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Controller, Get } from '@nestjs/common';

import { AppService } from './app.service';

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}

@Get()
getData() {
return this.appService.getData();
}
}
11 changes: 11 additions & 0 deletions apps/api/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';

import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
21 changes: 21 additions & 0 deletions apps/api/src/app/app.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Test } from '@nestjs/testing';

import { AppService } from './app.service';

describe('AppService', () => {
let service: AppService;

beforeAll(async () => {
const app = await Test.createTestingModule({
providers: [AppService],
}).compile();

service = app.get<AppService>(AppService);
});

describe('getData', () => {
it('should return "Welcome to api!"', () => {
expect(service.getData()).toEqual({ message: 'Welcome to api!' });
});
});
});
8 changes: 8 additions & 0 deletions apps/api/src/app/app.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class AppService {
getData(): { message: string } {
return { message: 'Welcome to api!' };
}
}
Empty file added apps/api/src/assets/.gitkeep
Empty file.
3 changes: 3 additions & 0 deletions apps/api/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const environment = {
production: true,
};
3 changes: 3 additions & 0 deletions apps/api/src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const environment = {
production: false,
};
21 changes: 21 additions & 0 deletions apps/api/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* This is not a production server yet!
* This is only a minimal backend to get started.
*/

import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';

import { AppModule } from './app/app.module';

async function bootstrap() {
const app = await NestFactory.create(AppModule);
const globalPrefix = 'api';
app.setGlobalPrefix(globalPrefix);
const port = process.env.PORT || 3333;
await app.listen(port, () => {
Logger.log('Listening at http://localhost:' + port + '/' + globalPrefix);
});
}

bootstrap();
12 changes: 12 additions & 0 deletions apps/api/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["node"],
"emitDecoratorMetadata": true,
"target": "es2015"
},
"exclude": ["**/*.spec.ts"],
"include": ["**/*.ts"]
}
13 changes: 13 additions & 0 deletions apps/api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
9 changes: 9 additions & 0 deletions apps/api/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["**/*.spec.ts", "**/*.d.ts"]
}
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
module.exports = {
projects: ['<rootDir>/apps/lightning'],
projects: [
'<rootDir>/apps/lightning',
'<rootDir>/apps/api',
'<rootDir>/libs/interfaces',
'<rootDir>/libs/contracts',
],
};
3 changes: 3 additions & 0 deletions libs/contracts/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]]
}
21 changes: 21 additions & 0 deletions libs/contracts/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"parserOptions": {
"project": ["libs/contracts/tsconfig.*?.json"]
},
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions libs/contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# contracts

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test contracts` to execute the unit tests via [Jest](https://jestjs.io).
14 changes: 14 additions & 0 deletions libs/contracts/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
displayName: 'contracts',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
},
},
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/libs/contracts',
};
1 change: 1 addition & 0 deletions libs/contracts/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/contracts';
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { IBaseSearchQuery } from '../generic';

// tslint:disable-next-line:no-empty-interface
export interface IAccountQuery extends IBaseSearchQuery {}
35 changes: 35 additions & 0 deletions libs/contracts/src/lib/contracts/account/account.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { ICoreNode } from '../../core-node.interface';

/**
* A base account with a running balance
*
* @export
* @interface IAccount
*/
export interface IAccount extends ICoreNode {
/**
* The type of the given account
*
* @type {string}
* @memberof IAccount
*/
type: string;

/**
* Friendly name for the account
*
* @example Checking Account
*
* @type {string}
* @memberof IAccount
*/
name: string;

/**
* The running balance of the account, this is really a collection of the transactions linked to it.
*
* @type {number}
* @memberof IAccount
*/
balance: number;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { IAccount } from './account.interface';

/**
* Interface to be implemented when creating an account
*
* @export
* @interface IAccountCreate
* @extends {Omit<IAccount, 'id'>}
*/
export interface ICreateAccount extends Omit<IAccount, 'id'> {}
3 changes: 3 additions & 0 deletions libs/contracts/src/lib/contracts/account/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type { IAccount } from './account.interface';
export type { ICreateAccount } from './create-account.interface';
export type { IAccountQuery } from './account-query.interface';
13 changes: 13 additions & 0 deletions libs/contracts/src/lib/contracts/budget/budget-query.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { IBaseSearchQuery } from '../generic';

/**
* Query object to run a search over the budget nodes
*
* @export
* @interface IBudgetQuery
*/
export interface IBudgetQuery extends Omit<IBaseSearchQuery, 'budgetId'> {
/**
* TODO: Enable additional props for IBudgetQuery - https://3.basecamp.com/4326074/buckets/14452756/todos/2444425808
*/
}
33 changes: 33 additions & 0 deletions libs/contracts/src/lib/contracts/budget/budget.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { ICoreNode } from '../../core-node.interface';

/**
* Interface that is used after a budget has been created
*
* @export
* @interface IBudget
*/
export interface IBudget extends Omit<ICoreNode, 'budgetId'> {
/**
* Unique ID for the budget
*
* @type {string}
* @memberof IBudget
*/
id: string;

/**
* The nicely formatted name of the budget
*
* @type {string}
* @memberof IBudget
*/
name: string;

/**
* Date the budget was started
*
* @type {string}
* @memberof IBudget
*/
createdDate: string;
}
18 changes: 18 additions & 0 deletions libs/contracts/src/lib/contracts/budget/create-budget.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { ICoreNode } from '../../core-node.interface';

/**
* Used to create a budget
*
* @export
* @interface ICreateBudget
*/
export interface ICreateBudget extends Omit<ICoreNode, 'id' | 'budgetId'> {
/**
* Name of the budget
*
* @example "Money Pit"
* @type {string}
* @memberof ICreateBudget
*/
name: string;
}
4 changes: 4 additions & 0 deletions libs/contracts/src/lib/contracts/budget/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type { IBudgetQuery } from './budget-query.interface';
export type { IBudget } from './budget.interface';
export type { ICreateBudget } from './create-budget.interface';
export type { IUpdateBudget } from './update-budget.interface';
11 changes: 11 additions & 0 deletions libs/contracts/src/lib/contracts/budget/update-budget.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { IBudget } from './budget.interface';

/**
* Interface that is used whenever a new budget is updated
*
* @export
* @interface IUpdateBudget
* @extends {Omit<IBudget, 'startDate'>}
*/
export interface IUpdateBudget
extends Omit<IBudget, 'startDate' | 'createdDate'> {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { IBaseSearchQuery } from '../generic';

/**
* Search request to find a category
*
* @export
* @interface ICategoryQuery
*/
export interface ICategoryQuery extends IBaseSearchQuery {}
Loading

0 comments on commit a317e35

Please sign in to comment.