Skip to content

Commit

Permalink
feat: [HOMETASK-1] create node web server (#1)
Browse files Browse the repository at this point in the history
* feat: [HOMETASK-1] create node web server

- setup nx monorepo
- migrate quoteApp to monorepo
- create quotes API
- serve quoteApp with api server
- add aws templates to libs
- remove duplicate jest config for client app
- QuoteService implements/extends repo
- JsonDb as an independent module
- style
  • Loading branch information
boale committed Nov 4, 2021
1 parent 43ad428 commit 7ccaef7
Show file tree
Hide file tree
Showing 239 changed files with 29,958 additions and 1,346 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Expand Up @@ -2,11 +2,14 @@
root = true

[*]

charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
tab_width = 2
max_line_length = 120

[*.md]
max_line_length = off
Expand Down
8 changes: 8 additions & 0 deletions .gitattributes
@@ -0,0 +1,8 @@
# prettier v2 dictates LF
# https://prettier.io/docs/en/options.html#end-of-line
* text=auto eol=lf

.vscode/*.json linguist-language=jsonc
tslint.json linguist-language=jsonc
tsconfig.json linguist-language=jsonc
tsconfig.*.json linguist-language=jsonc
1 change: 1 addition & 0 deletions .husky/.gitignore
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run affected:lint
4 changes: 4 additions & 0 deletions .husky/pre-push
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm affected:test
1 change: 1 addition & 0 deletions .npmrc
@@ -0,0 +1 @@
engine-strict = true
3 changes: 3 additions & 0 deletions .nxignore
@@ -0,0 +1,3 @@
libs/buildspecs/*
libs/cf-templates/*
libs/maintenance/*
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Oleksandr Bondarenko

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
15 changes: 11 additions & 4 deletions angular.json
Expand Up @@ -28,7 +28,8 @@
"unitTestRunner": "jest"
},
"@nrwl/angular:component": {
"style": "scss"
"style": "scss",
"changeDetection": "OnPush"
}
},
"projects": {
Expand All @@ -47,8 +48,14 @@
"polyfills": "apps/quotes/src/polyfills.ts",
"tsConfig": "apps/quotes/tsconfig.app.json",
"aot": true,
"assets": ["apps/quotes/src/favicon.ico", "apps/quotes/src/assets"],
"styles": ["apps/quotes/src/styles.scss"],
"assets": [
"apps/quotes/src/favicon.ico",
"apps/quotes/src/assets"
],
"styles": [
"node_modules/ngx-toastr/toastr.css",
"apps/quotes/src/styles.scss"
],
"scripts": []
},
"configurations": {
Expand Down Expand Up @@ -104,7 +111,7 @@
"options": {
"lintFilePatterns": [
"apps/quotes/src/**/*.ts",
"apps/quotes/src/**/*.html"
"apps/quotes/src/**/*.component.html"
]
}
},
Expand Down
1 change: 1 addition & 0 deletions apps/api/.npmrc
@@ -0,0 +1 @@
prefix = ../../
5 changes: 5 additions & 0 deletions apps/api/.versionrc
@@ -0,0 +1,5 @@
{
"path": ".",
"tag-prefix": "quotes-api-v",
"releaseCommitMessageFormat": "chore(release): quotes-api@{{currentTag}}"
}
2 changes: 2 additions & 0 deletions apps/api/README.md
@@ -0,0 +1,2 @@
# Quotes API

17 changes: 17 additions & 0 deletions apps/api/package.json
@@ -0,0 +1,17 @@
{
"name": "quotes-api",
"version": "0.0.0",
"description": "",
"keywords": [],
"homepage": "https://github.com/boale/quotes/tree/main/apps/api#readme",
"bugs": {
"url": "https://github.com/boale/quotes/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/boale/quotes",
"directory": "apps/api"
},
"license": "MIT",
"author": "Oleksandr Bondarenko"
}
15 changes: 9 additions & 6 deletions apps/api/src/app/app.controller.spec.ts
@@ -1,22 +1,25 @@
import { Test, TestingModule } from '@nestjs/testing';

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

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

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

describe('getData', () => {
it('should return "Welcome to api!"', () => {
const appController = app.get<AppController>(AppController);
expect(appController.getData()).toEqual({ message: 'Welcome to api!' });
beforeEach(async () => {
appController = app.get<AppController>(AppController);
});

describe('health-check', () => {
it('should return health-check object', () => {
expect(appController.ping()).toEqual({ statusCode: 200, message: 'OK' });
});
});
});
11 changes: 3 additions & 8 deletions apps/api/src/app/app.controller.ts
@@ -1,15 +1,10 @@
import { Controller, Get } from '@nestjs/common';

import { Message } from '@quotes/api-interfaces';

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

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

@Get('hello')
getData(): Message {
return this.appService.getData();
@Get([ 'ping', 'health' ])
ping() {
return { statusCode: 200, message: 'OK' };
}
}
22 changes: 18 additions & 4 deletions apps/api/src/app/app.module.ts
@@ -1,11 +1,25 @@
import { Module } from '@nestjs/common';
import { ServeStaticModule } from '@nestjs/serve-static';

import { join } from 'path';

import { isDev } from "./shared/utils";
import { QuotesModule } from "./quotes/quotes.module";
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
imports: [
QuotesModule,
// TODO: remove once it split into separate apps in further tasks...
...(
!isDev() ? [
ServeStaticModule.forRoot({
rootPath: join(__dirname, 'assets', 'client'),
exclude: ['/api*', '/ping', '/health'],
}) ,
] : []
),
],
controllers: [ AppController ],
})
export class AppModule {}
21 changes: 0 additions & 21 deletions apps/api/src/app/app.service.spec.ts

This file was deleted.

9 changes: 0 additions & 9 deletions apps/api/src/app/app.service.ts

This file was deleted.

3 changes: 3 additions & 0 deletions apps/api/src/app/json-db-collection/index.ts
@@ -0,0 +1,3 @@
export * from './models';
export * from './utils';
export * from './json-db-collection.service';

0 comments on commit 7ccaef7

Please sign in to comment.