Skip to content

Commit

Permalink
chore(module): creates issue templates, coc, and contributing guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcdo29 committed Mar 28, 2020
1 parent 34382e1 commit 64bb596
Show file tree
Hide file tree
Showing 41 changed files with 12,468 additions and 192 deletions.
9 changes: 6 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@ module.exports = {
jest: true,
},
rules: {
// 'max-len': ['error', { code: 80, ignoreTemplateLiterals: true }],
'no-control-regex': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'sonarjs/cognitive-complexity': ['error', 20],
'sort-imports': [
'error',
{ ignoreDeclarationSort: true, ignoreCase: true },
],
},
ignorePatterns: ['*.d.ts', 'dist/*', 'packages/**/node_modules/*'],
ignorePatterns: ['*.d.ts', 'dist/*', '**/node_modules/*', 'lib/*'],
globals: {
WeakSet: 'readonly',
Promise: 'readonly',
Reflect: 'readonly'
Reflect: 'readonly',
},
};
43 changes: 43 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_Report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: "\U0001F41B Bug Report"
about: "If something isn't working as expected \U0001F914."
title: '[Bug]:'
labels: 'type: potential issue :broken_heart:'
assignees: ''
---

## Bug Report

## Current behavior

<!-- Describe how the issue manifests. -->

## Input Code

<!-- REPL or Repo link if applicable: -->

```ts
const your = (code) => here;
```

## Expected behavior

<!-- A clear and concise description of what you expected to happen (or code). -->

## Possible Solution

<!--- Only if you have suggestions on a fix for the bug -->

## Environment

<pre><code>
@ogma/nestjs-module version: X.Y.Z
<!-- Check whether this is still an issue in the most recent @ogma/nestjs-module version -->

For Tooling issues:
- Node version: XX <!-- run `node --version` -->
- Platform: <!-- Mac, Linux, Windows -->

Others:
<!-- Anything else relevant? Operating system version, IDE, package manager, ... -->
</code></pre>
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/Parser_Request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: "\U0001F680 Feature Request"
about: "I have a suggestion \U0001F63B!"
title: '[Parser]:'
labels: 'type: enhancement :wolf:'
assignees: ''
---

## Feature Request

## Is your feature request related to a problem? Please describe.

<!-- A clear and concise description of what the problem is. Ex. I have an issue when [...] -->

## Describe the solution you'd like

<!-- A clear and concise description of what you want to happen. Add any considered drawbacks. -->

## Teachability, Documentation, Adoption, Migration Strategy

<!-- If you can, explain how users will be able to use this and possibly write out a version the docs. Maybe a screenshot or design? -->

## What is the motivation / use case for changing the behavior?

<!-- Describe the motivation or the concrete use case. -->
56 changes: 56 additions & 0 deletions .github/ISSUE_TEMPLATE/Regression.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
name: "\U0001F4A5 Regression"
about: Report an unexpected while upgrading your @ogma/nestjs-module version!
title: '[Regression]:'
labels: 'type: bug :sob:'
assignees: ''
---

## Regression

## Potential Commit/PR that introduced the regression\*\*

<!-- If you have time to investigate, what PR/date introduced this issue. -->

## Describe the regression

<!-- A clear and concise description of what the regression is. -->

## Input Code

<!--- If you have link to our REPL or a standalone repo please link that! -->

```ts
const your = (code) => here;
```

## Expected behavior/code

<!-- A clear and concise description of what you expected to happen (or code). -->

## Environment

<pre><code>
@ogma/nestjs-module version: X.Y.Z
Affected Platform:
[] Express
[] Fastify
[] Graphql
[] Graphql-Fastify
[] gRPC
[] Kafka
[] MQTT
[] NATS
[] RabbitMQ
[] Redis
[] Socket.io
[] TCP
[] WS

For Tooling issues:
- Node version: XX <!-- run `node --version` -->
- Platform: <!-- Mac, Linux, Windows -->

Others:
<!-- Anything else relevant? Operating system version, IDE, package manager, ... -->
</code></pre>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# compiled output
lib/
dist/
node_modules/
*.tsbuildinfo

Expand Down
79 changes: 79 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our community include:

- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior include:

- The use of sexualized language or imagery, and sexual attention or advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [[email protected]](mailto:[email protected]). All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of actions.

**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ Any and all contributions are welcome! This is a decently sized project with a g
5. Push back to your version on GitHub
6. Raise a Pull Request to the main repository

## Local Testing
## Development

Besides unit and e2e tests, there is also the ability to just run a local NestJS application with the `OgmaModule` imported into it. This code is already setup and ready to be worked with as necessary, all you need to do is `npm run build:all` to build both the `OgmaModule` code and the NestJS application and then `npm run start:test` to start the test application. From there, you can use Postman, cURL, the Node REPL, or any other method of testing you find pleasing to use.
We are using [lerna](https://github.com/lerna/lerna) to help manage the monorepo, to build and manage the code, it is _suggested_ to use [yarn](https://classic.yarnpkg.com/en/docs/getting-started) as it has better support for workspaces and automatic linking between the packages. If you are creating a new package inside the monorepo you can use `lerna create` and follow the wizard from there. Make sure you name the package as `@ogma/platform-<platform-name>` to follow the naming scheme of the library.

### Breaking apart the builds
If you are adding in a new library, please also add in integration tests for the library following the examples in [integration](integration/).

If you need to only recompile the library code, you can use `npm run build` to build the main lib.
To build your the project and link the dependencies together you can run `lerna run build`.

Similarly if you only need to rebuild the NestJS server, use `npm run build:test`.
When running the integration specific applications in a non--testing context (i.e. starting them locally), make sure to `cd` into the directory, `yarn install` the dependencies, and then run `yarn build && yarn start` to compile and start the server. From there, in a separate terminal, you can use [curl](https://curl.haxx.se/) or [Postman](https://www.postman.com/), or just use the browser directly. For websocket testing, you can use the node REPL (i.e. use `node` from the terminal) and make websocket calls from there.

## Issues

Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# @Omga
# @omga

Ogma is a simple, no-nonsense logger developed to make logging simple, and easy to read in development, while also having a powerful JSON form when it comes to production level logs, to make it easier to parse and consume by external services. This monorepo has all of the code for the base logger, the binary to rehydrate the JSON logs, and the [NestJS Module](https://nestjs.com) along with supported plugins for the module's interceptor.

## Packages

| Package | Description |
| --- | --- |
| @ogma/logger | The base logger package that has the core implementation. Can be used from anything, does not need to be NestJS. Also contains the ogma binary fro log rehydration |
| @ogma/nestjs-module | The core module package that sets up the `OgmaService` and `OgmaInterceptor` |
| @ogma/platform-express | A plugin for the OgmaInterceptor to properly handle HTTP requests from [Express](http://expressjs.com) |
| @ogma/platform-fastify | An HTTP plugin to properly log [Fastify](https://www.fastify.io/) requests |
| @ogma/platform-graphql | An HTTP/GQL plugin to properly log [GraphQL](https://www.apollographql.com/docs/) requests using the Express server |
| @ogma/platform-graphql-fastify | An HTTP/GQL plugin to properly log [GraphQL](https://www.apollographql.com/docs/) requests using the Fastify server |
| @ogma/platform-grpc | A microservice plugin to properly log [gRPC](https://docs.nestjs.com/microservices/gRPC) requests |
| @ogma/platform-kafka | A microservice plugin to properly log [Kafka](https://docs.nestjs.com/microservices/kafka) requests |
| @ogma/platform-mqtt | A microservice plugin to properly log [MQTT](https://docs.nestjs.com/microservices/mqtt) requests |
| @ogma/platform-nats | A microservice plugin to properly log [NATS](https://docs.nestjs.com/microservices/nats) requests |
| @ogma/platform-rabbitmq | A microservice plugin to properly log [RabbitMQ](https://docs.nestjs.com/microservices/rabbitmq) requests |
| @ogma/platform-redis | A microservice plugin to properly log [Redis](https://docs.nestjs.com/microservices/redis) requests |
| @ogma/platform-socket.io | A Gateway plugin to properly log [Socket.io](https://socket.io) requests |
| @ogma/platform-tcp | A microservice plugin to properly log [TCP](https://docs.nestjs.com/microservices/basics) requests |
| @ogma/platform-ws | A Gateway plugin to properly log [WS](https://github.com/websockets/ws) requests |
| [@ogma/logger](packages/logger) | The base logger package that has the core implementation. Can be used from anything, does not need to be NestJS. Also contains the ogma binary fro log rehydration |
| [@ogma/nestjs-module](packges/nestjs-module) | The core module package that sets up the `OgmaService` and `OgmaInterceptor` |
| [@ogma/platform-express](packges/platform-express) | A plugin for the OgmaInterceptor to properly handle HTTP requests from [Express](http://expressjs.com) |
| [@ogma/platform-fastify](packges/platform-fastify) | An HTTP plugin to properly log [Fastify](https://www.fastify.io/) requests |
| [@ogma/platform-graphql](packges/platform-graphql) | An HTTP/GQL plugin to properly log [GraphQL](https://www.apollographql.com/docs/) requests using the Express server |
| [@ogma/platform-graphql-fastify](packges/platform-graphql-fastify) | An HTTP/GQL plugin to properly log [GraphQL](https://www.apollographql.com/docs/) requests using the Fastify server |
| [@ogma/platform-grpc](packges/platform-grpc) | A microservice plugin to properly log [gRPC](https://docs.nestjs.com/microservices/gRPC) requests |
| [@ogma/platform-kafka](packges/platform-kafka) | A microservice plugin to properly log [Kafka](https://docs.nestjs.com/microservices/kafka) requests |
| [@ogma/platform-mqtt](packges/platform-mqtt) | A microservice plugin to properly log [MQTT](https://docs.nestjs.com/microservices/mqtt) requests |
| [@ogma/platform-nats](packges/platform-nats) | A microservice plugin to properly log [NATS](https://docs.nestjs.com/microservices/nats) requests |
| [@ogma/platform-rabbitmq](packges/platform-rabbitmq) | A microservice plugin to properly log [RabbitMQ](https://docs.nestjs.com/microservices/rabbitmq) requests |
| [@ogma/platform-redis](packges/platform-redis) | A microservice plugin to properly log [Redis](https://docs.nestjs.com/microservices/redis) requests |
| [@ogma/platform-socket.io](packges/platform-socket.io) | A Gateway plugin to properly log [Socket.io](https://socket.io) requests |
| [@ogma/platform-tcp](packges/platform-tcp) | A microservice plugin to properly log [TCP](https://docs.nestjs.com/microservices/basics) requests |
| [@ogma/platform-ws](packges/platform-ws) | A Gateway plugin to properly log [WS](https://github.com/websockets/ws) requests |
Empty file added integration/.gitkeep
Empty file.
24 changes: 24 additions & 0 deletions integration/express/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@ogma/platform-express-integration",
"version": "0.0.0",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"start": "nest start"
},
"private": true,
"dependencies": {
"@nestjs/common": "^7.0.0",
"@nestjs/core": "^7.0.0",
"@nestjs/platform-express": "^7.0.0"
},
"devDependencies": {
"@nestjs/testing": "^7.0.0",
"@nestjs/cli": "^7.1.1",
"jest": "^25.2.3",
"rimraf": "^3.0.2",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.4",
"ts-jest": "^25.2.1"
}
}
30 changes: 30 additions & 0 deletions integration/express/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { BadRequestException, Controller, Get, HttpCode } from '@nestjs/common';
import { OgmaSkip } from '@ogma/nestjs-module';
import { AppService } from './app.service';

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

@Get()
getHello(): string {
return this.appService.getHello();
}

@Get('status')
@HttpCode(204)
getStatus(): string {
return this.appService.getHello();
}

@Get('error')
getError(): string {
throw new BadRequestException();
}

@Get('skip')
@OgmaSkip()
getSkip(): string {
return this.appService.getHello();
}
}
18 changes: 18 additions & 0 deletions integration/express/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Module } from '@nestjs/common';
import { OgmaModule } from '@ogma/nestjs-module';
import { ExpressInterceptorParser } from '@ogma/platform-express';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
imports: [
OgmaModule.forRoot({
interceptor: {
http: ExpressInterceptorParser,
},
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';

@Injectable()
export class AppService {
getSimpleMessage(): object {
return { message: 'Hello World!' };
getHello(): string {
return 'Hello World!';
}
}
12 changes: 12 additions & 0 deletions integration/express/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { NestFactory } from '@nestjs/core';
import { OgmaService } from '@ogma/nestjs-module';
import { AppModule } from './app.module';

async function bootstrap() {
const app = await NestFactory.create(AppModule);
const logger = app.get(OgmaService);
await app.listen(process.env.POR || 3000);
logger.log(`Nest-Express listening at ${await app.getUrl()}`);
}

bootstrap();
Loading

0 comments on commit 64bb596

Please sign in to comment.