Skip to content

Commit

Permalink
updated readmes more and added .madgerc
Browse files Browse the repository at this point in the history
  • Loading branch information
devlinjunker committed Mar 22, 2020
1 parent e77f07e commit 0c39837
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 43 deletions.
3 changes: 3 additions & 0 deletions .madgerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"excludeRegExp": [".*\\.spec\\.js", "package\\.json"]
}
14 changes: 8 additions & 6 deletions README.logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

We are currently using pino for logging. Pino logs objects/messages directly to streams so other processes can
actually handle formatting or other log actions (this is because Node is single threaded, so smarter to create
another process to manage the logs). We store all of these files in `<CONFIG.LOG.dir>/pino.log`
another process to manage the logs). We store all of these logs in `<CONFIG.LOG.dir>/pino.log`

## Configurations

Expand Down Expand Up @@ -39,12 +39,12 @@ controller({ params, logger }: HapiRequest) {


## Other processes
Other node processes should be spawned (in production and development), here are some examples of processes
we recommend:
By design, pino just outputs logs to be used by other "transporters" (other node processes spawned in
production and development) for reacting to, and viewing these logs. here are some examples of processes
we recommend implementing:

### Logrotate
By design, pino just outputs logs to be used by other "transporters". Log Rotation should be handled via
another service as described in the [pino documention](http://getpino.io/#/docs/help?id=log-rotation)
Log Rotation on production servers should be handled via another service as described in the [pino documention](http://getpino.io/#/docs/help?id=log-rotation)

### Pino-Pretty
Displays the logs in a prettier format that makes it easier to see the data, however takes up more space.
Expand Down Expand Up @@ -97,8 +97,10 @@ e.g.


## Notes/Ideas
- Log Helper for use in the dataservices
- Trace logging any external requests/responses
- Logger Helper for use in the dataservices
- goaccess?
- websocket? endpoint that shows logs in real time
- docs page for logs (searching?)
- Elasticsearch/Logstash/Kibana
- logrotate on production
7 changes: 4 additions & 3 deletions README.setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ manage node versions is by using the [Node Version Manager](https://github.com/n
in the project to help reference this minimum node version.

Use `nvm use 10` to switch node versions after installing a new Node version. **Then you should install all
project dependencies**([github](https://github.com/devlinjunker/template.node.hapi/blob/master/package.json#L30))
project dependencies**([github](https://github.com/devlinjunker/template.node.hapi/blob/master/package.json#L30))
with `npm install` (or `npm install -D` if development work is planned). This should install the Hapi Server Framework,
MariaDB and other libraries used in this project.

Expand All @@ -30,7 +30,7 @@ and create Postman test suites based on these files)
## Webpack

Webpack config file([github](https://github.com/devlinjunker/template.node.hapi/blob/master/webpack.config.js))
is used to manage our webpack build to compile the application.
is used to manage our webpack build to compile the application.

In this file we:
- designate the files that will be created with the build
Expand All @@ -52,11 +52,12 @@ The Dependency Graph is created with [Madge](https://github.com/pahen/madge) and
install both in order to update the dependency graph. I didn't include these in the package.json dependencies
because I felt this is more than is needed to develop a working app or even write basic documentation.

Install madge with `npm install madge` and install graphviz with `brew install graphviz` or
Install madge with `npm install -g madge` and install graphviz with `brew install graphviz` or
`port install graphviz` (for OSX)

I split this out to a separate npm script: `npm run doc-image`


## Notes/Ideas
- **IDEA:** init scripts with installation and SQL setup
- Explore madge options: https://www.npmjs.com/package/madge#configuration
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"build": "./node_modules/.bin/webpack",
"clean": "rm -rf ./dist",
"help": "echo \"$(cat help.txt)\"",
"doc-image": "./node_modules/madge/bin/cli.js ./src -x '.*\\.spec\\.js' -i docs/image/dependency.png & npm run doc"
"doc-image": "madge ./src -i docs/image/dependency.png & npm run doc"
},
"husky": {
"hooks": {
Expand Down
10 changes: 9 additions & 1 deletion scripts/hooks/README.hooks.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Git Hooks
# Git Hooks/Workflow

We use githooks([github](https://github.com/devlinjunker/template.node.hapi/tree/master/scripts/hooks)) to help clean up and enforce the workflow for developers. This is done with Husky.

Expand All @@ -12,3 +12,11 @@ Process:
1. Stash uncommited changes
2. Run linting/flow/compliation and tests with npm/webpack
3. Pop uncommitted changes


## Github Actions

We setup github actions on this project so we can attempt to build and run the tests for every PR submitted
against master.

More to come...
31 changes: 12 additions & 19 deletions src/dataservices/README.dataservices.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
# Dataservices

Dataservices communicate with storage systems or external APIs to fetch/store data.
Dataservices abstract the communication with storage systems or external APIs to fetch/store data related to a
topic or for a specific UI component.

## Examples

## Hello World

Simple example of Hello World endpoint plus example with random value and input from path parameter

## Note Dataservice

### Note Dataservice
Create/Read Note objects out of a mariadb/mysql database


## Notes/Ideas
- RDBMS vs Document store
- CAP theorem stands for C – Consistency, A — Availability, P — Partitioning (or Scalability) and states that having all three properties at the same time is not possible,
- https://medium.com/statuscode/three-reasons-to-use-a-nosql-document-store-for-your-next-web-application-6b9eabffc8d8
- Document Store:
- use for settings data and where schema will be changed often
- when changes are small crud, based on users interactions?
- when count and aggregate data is useful to end user
- RDBMS:
- less duplicated data, normalized and stored in specific tables
- useful when data changes often
- seems like more useful for storing fact data in ETL processes?
- Q: phoenix?
- Quick storage dataservice (abstracted away from specific object?)
- takes object from post/put request and places in mongodb
- objects indexed by another param
- automatically assigned id
- retrieves with get request
- delete request
- takes multiple object ids
- search/or retrieve by property?
34 changes: 25 additions & 9 deletions src/helpers/README.helpers.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
# Helpers

Helpers are classes that wrap some functionality not associated with an external service
Helpers are classes that modularize some functionality that is useful in the server.

## MariaDB
- connecting with mariadb server
## Examples

### MariaDB
Helper class for connecting with mariadb server and saving/retrieving rows from tables
- query
- insert
- fetch
- fetchOne

## Config
- reading properties from [config file](https://github.com/devlinjunker/template.node.hapi/blob/master/conf/config.yaml#L3)

## Healthcheck
- Make simple requests to configured DB/External Services to see if available
### Config
Helper class for reading properties from [config file](https://github.com/devlinjunker/template.node.hapi/blob/master/conf/config.yaml#L3)
- provides a typed interface of these properties

### Healthcheck
Helper for building the healthcheck response that is displayed at `<CONFIG.PATHS.healthceck>` endpoint.
- Determines version/branch and if the server is running properly
- Makes simple requests to configured dependency DB/External Services to see if they are available



## Notes/Ideas
- **IDEA:** Should healthcheck read log file for past minute to see if any errors?
- Do we want/need to worry about Dependency Injection/Singletons?
- **IDEA:** Move Server into helpers as `server.helper.js`?
- RDBMS vs Document store
- CAP theorem stands for C – Consistency, A — Availability, P — Partitioning (or Scalability) and states that having all three properties at the same time is not possible,
- https://medium.com/statuscode/three-reasons-to-use-a-nosql-document-store-for-your-next-web-application-6b9eabffc8d8
- Document Store:
- use for settings data and where schema will be changed often
- when changes are small crud, based on users interactions?
- when count and aggregate data is useful to end user
- RDBMS:
- less duplicated data, normalized and stored in specific tables
- useful when data changes often
- seems like more useful for storing fact data in ETL processes?
- Q: phoenix?

0 comments on commit 0c39837

Please sign in to comment.