Skip to content

Commit

Permalink
Merge branch 'release/2.0.26'
Browse files Browse the repository at this point in the history
  • Loading branch information
claytonsilva committed Mar 28, 2017
2 parents aaa94e8 + b552a47 commit 43c2685
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 31 deletions.
11 changes: 5 additions & 6 deletions lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ export class Application {

handleEnableCORS (app: express.Application): express.Application {
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', process.env.CORSALLOWED || '*')
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS,PATCH')
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type,' +
' Accept, Authorization, If-Modified-Since, Cache-Control, enctype, Pragma')
res.header('Access-Control-Allow-Origin', this.appConfig.getCorsAllowed())
res.header('Access-Control-Allow-Methods', this.appConfig.getCorsAllowMethods())
res.header('Access-Control-Allow-Headers', this.appConfig.getCorsAllowHeaders())
if ('OPTIONS' === req.method) {
return res.send(200)
} else {
Expand Down Expand Up @@ -112,7 +111,7 @@ export class Application {
if (!(err instanceof Services.APIError)) {
err = new Services.APIError(err, err.status || err.statusCode || 500)
}
return res.status(err.statusCode >= 100 && err.statusCode < 600 ? err.statusCode : 500).json(err.error)
return res.sendStatus(err.statusCode >= 100 && err.statusCode < 600 ? err.statusCode : 500).json(err.error)
})
}

Expand All @@ -122,7 +121,7 @@ export class Application {
if (!(err instanceof Services.APIError)) {
err = new Services.APIError(err, err.status || err.statusCode || 500)
}
return res.status(err.statusCode >= 100 && err.statusCode < 600 ? err.statusCode : 500).json(err.error)
return res.sendStatus(err.statusCode >= 100 && err.statusCode < 600 ? err.statusCode : 500).json(err.error)
})
return app
}
Expand Down
20 changes: 19 additions & 1 deletion lib/config/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ export class AppConfig {
private signUpUrl: string
private forgotUrl: string

private corsAllowed: string
private corsAllowMethods: string
private corsAllowHeaders: string

constructor () {
this.corsAllowed = getEnv('CORSALLOWED') || '*'
this.corsAllowMethods = getEnv('CORS_ALLOW_METHODS') || 'GET,PUT,POST,DELETE,OPTIONS,PATCH'
this.corsAllowHeaders = getEnv('CORS_ALLOW_HEADERS') || 'Origin, X-Requested-With, Content-Type, Accept, Authorization, If-Modified-Since, Cache-Control, enctype, Pragma'
this.mainCompany = getEnv('MAIN_COMPANY')
this.isProd = ( process.env.NODE_ENV === 'production' )
this.isProd = ( getEnv('NODE_ENV') === 'production' )
this.cryptoAlgorithm = getEnv('CRYPTO_ALGORITHM') || 'aes192'
this.cryptoPassword = getEnv('CRYPTO_PASSWORD')
this.expirationDays = Number.parseInt( getEnv('EXPIRATION_DAYS'), 10 ) || 3
Expand Down Expand Up @@ -73,4 +80,15 @@ export class AppConfig {
return this.forgotUrl
}

getCorsAllowed (): string {
return this.corsAllowed
}
getCorsAllowMethods (): string {
return this.corsAllowMethods
}

getCorsAllowHeaders (): string {
return this.corsAllowHeaders
}

}
48 changes: 24 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"name": "js-data-dao",
"main": "lib/index.js",
"typings": "lib/index.ts",
"version": "2.0.25",
"version": "2.0.26",
"description": "js-data-dao",
"license": "MIT",
"repository": "https://github.com/xdevelsistemas/js-data-dao",
"author": "Clayton Santos da Silva",
"scripts": {
"builder:compile": "gulp ts",
"test": "gulp coveralls",
"builder:doc" : "typedoc --hideGenerator --excludeExternals --target ES6 --mode file --out docs --tsconfig tsdoc.json && touch docs/.nojekyll"
"builder:doc": "typedoc --hideGenerator --excludeExternals --target ES6 --mode file --out docs --tsconfig tsdoc.json && touch docs/.nojekyll"
},
"keywords": [
"xdevel"
Expand All @@ -21,44 +21,44 @@
"lib/**/*.js.map"
],
"dependencies": {
"body-parser": "^1.16.1",
"body-parser": "^1.17.1",
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"email-validator": "^1.0.7",
"express": "^4.14.1",
"express": "^4.15.2",
"fs-extra-promise": "^0.4.1",
"js-data": "3.0.0-rc.9",
"js-data-rethinkdb": "https://github.com/xdevelsistemas/js-data-rethinkdb#stable",
"jsonwebtoken": "^7.3.0",
"nodemailer": "^3.1.3",
"nodemailer": "^3.1.8",
"nodemailer-smtp-transport": "^2.7.2",
"passport": "^0.3.2",
"passport-jwt": "^2.2.1",
"rethinkdbdash": "^2.3.28",
"shortid": "^2.2.6"
"shortid": "^2.2.8"
},
"devDependencies": {
"@types/bluebird": "^3.0.37",
"@types/body-parser": "^0.0.34",
"@types/bluebird": "^3.5.2",
"@types/body-parser": "^1.16.2",
"@types/boom": "^0.0.33",
"@types/chai-as-promised": "^0.0.29",
"@types/chai-as-promised": "^0.0.30",
"@types/cookie-parser": "^1.3.30",
"@types/email-validator": "^1.0.30",
"@types/express": "^4.0.35",
"@types/fs-extra-promise": "^0.0.31",
"@types/gulp": "^3.8.32",
"@types/gulp-istanbul": "^0.9.30",
"@types/gulp-mocha": "^0.0.29",
"@types/gulp-sourcemaps": "^0.0.29",
"@types/handlebars": "^4.0.31",
"@types/gulp": "^4.0.2",
"@types/gulp-istanbul": "^0.9.31",
"@types/gulp-mocha": "^0.0.30",
"@types/gulp-sourcemaps": "^0.0.30",
"@types/handlebars": "^4.0.32",
"@types/jsonwebtoken": "^7.2.0",
"@types/lodash": "^4.14.52",
"@types/lodash": "^4.14.58",
"@types/morgan": "^1.7.32",
"@types/nodemailer": "^1.3.32",
"@types/shortid": "^0.0.28",
"@types/sinon": "^1.16.35",
"@types/sinon": "^1.16.36",
"@types/supertest": "^2.0.0",
"babel-eslint": "^7.1.1",
"babel-eslint": "^7.2.1",
"builder": "^3.2.1",
"builder-ts-library": "^0.0.6",
"gulp": "^3.9.1",
Expand All @@ -70,19 +70,19 @@
"gulp-print": "^2.0.1",
"gulp-sourcemaps": "^2.4.1",
"gulp-tslint": "^7.1.0",
"gulp-typescript": "^3.1.5",
"gulp-typescript": "^3.1.6",
"istanbul": "^0.4.5",
"jsdoc": "^3.4.3",
"mocha": "^3.2.0",
"nodemailer-mock": "^1.1.11",
"nodemailer-mock": "^1.2.1",
"nodemailer-mock-transport": "^1.3.0",
"remap-istanbul": "^0.9.1",
"sinon": "^1.17.7",
"remap-istanbul": "^0.9.5",
"sinon": "^2.1.0",
"supertest": "^3.0.0",
"ts-node": "^2.1.0",
"ts-node": "^3.0.2",
"tsdoc": "^0.0.4",
"tslint": "^4.4.2",
"tslint": "^4.5.1",
"tslint-config-standard": "^4.0.0",
"typescript": "^2.2.1"
"typescript": "^2.2.2"
}
}

0 comments on commit 43c2685

Please sign in to comment.