Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production declaration files #74

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 36 additions & 10 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
{
"extends": "standard",
"plugins": [
"standard",
"promise"
"env": {
"node": true,
"jest": true
},
"extends": [
"standard"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error"
],
"rules": {
"complexity": ["error", { "max": 5 }],
"max-depth": ["error", { "max": 1 }],
"no-new": [0],
"handle-callback-err": "warn"
}
"@typescript-eslint/member-delimiter-style": [
"error",
{
"multiline": {
"delimiter": "none",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
]
},
"ignorePatterns": [
"dist"
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ coverage

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
dist

# Dependency directories
node_modules
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,18 @@ We'll also skip status route, options method and body property from routes that

It's important to hide sentive information like api_key.

```js
const express = require('express')
const log4js = require('log4js').getLogger()
const escriba = require('escriba')
const cuid = require('cuid')
const roomController = require('./controllers/room')
```javascript
import express from 'express'
import log4js from 'log4js'
import escriba from 'escriba'
import cuid from 'cuid'
import roomController from './controllers/room'

const app = express()
const log4jsLogger = log4js.getLogger()

const { httpLogger } = escriba({
loggerEngine: log4js,
loggerEngine: log4jsLogger,
sensitive: {
password: {
paths: ['body.api_key'],
Expand Down
24 changes: 24 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: '8'
}
}
],
'@babel/preset-typescript'
],
plugins: [
['module-resolver', {
alias: {
'@escriba/integrations': './src/integrations',
'@escriba/utils': './src/utils'
}
}]
],
ignore: [
'test/**/*.spec.ts'
]
}
2 changes: 1 addition & 1 deletion examples/log-generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ app.post('/escriba', (req, res) => {
})

app.get('/escriba', (req, res) => {
res.send('This is a log-generator example!!!');
res.send('This is a log-generator example!!!')
})

app.listen(3000, () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/log-generator/lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const escribaConfig = {
},
loggerEngine: log4js.getLogger(),
service: 'Escriba App',
envToLog: ['SHELL', 'PATH'],
envToLog: ['SHELL', 'PATH'],
httpConf: {
propsToLog: {
request: [
Expand Down
25 changes: 25 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { compilerOptions } = require('./tsconfig.json')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obrigado por colocar Jest 😍

const { pathsToModuleNameMapper } = require('ts-jest/utils')

module.exports = {
clearMocks: true,
collectCoverage: true,
coverageDirectory: '<rootDir>//coverage',
coverageReporters: [
'text',
'lcov',
'html'
],
coverageProvider: 'babel',
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>'
}),
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: [
'**/test/**/*.spec.ts'
],
testPathIgnorePatterns: [
'/node_modules/'
]
}
Loading