Permalink
Browse files

Fix .eslintrc to use 2 spaces as indent style (#22)

* Fix  the .editorconfig to use TAB as indent style

The eslint config for indent style is defined as Tab, but in the
.editorconfig file it was space

* Update eslint and editorconfig to use spaces instead tab

* Replace all tabs with spaces
  • Loading branch information...
rafaelhz authored and kunalkapadia committed Jul 18, 2016
1 parent 4271999 commit 4ef4dac00171b3dd62dac556fcaceab846830391
View
@@ -10,4 +10,4 @@ trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
trim_trailing_whitespace = false
View
@@ -1,34 +1,34 @@
{
"rules": {
"indent": [
2,
"tab",
{
"SwitchCase": 1
}
],
"space-before-function-paren": [
2,
{
"anonymous": "always",
"named": "never"
}
],
"no-use-before-define": [
2,
"nofunc"
],
// TODO: turn on later
"comma-dangle": [
0
]
},
"env": {
"node": true,
"mocha": true
},
"extends": [
"eslint:recommended",
"airbnb/base"
]
}
"rules": {
"indent": [
2,
2,
{
"SwitchCase": 1
}
],
"space-before-function-paren": [
2,
{
"anonymous": "always",
"named": "never"
}
],
"no-use-before-define": [
2,
"nofunc"
],
// TODO: turn on later
"comma-dangle": [
0
]
},
"env": {
"node": true,
"mocha": true
},
"extends": [
"eslint:recommended",
"airbnb/base"
]
}
@@ -1,5 +1,5 @@
export default {
env: 'development',
db: 'mongodb://localhost/express-mongoose-es6-rest-api-development',
port: 3000
env: 'development',
db: 'mongodb://localhost/express-mongoose-es6-rest-api-development',
port: 3000
};
View
@@ -5,7 +5,7 @@ const env = process.env.NODE_ENV || 'development';
const config = require(`./${env}`);
const defaults = {
root: path.join(__dirname, '/..')
root: path.join(__dirname, '/..')
};
_.assign(config, defaults);
View
@@ -1,5 +1,5 @@
export default {
env: 'production',
db: 'mongodb://localhost/express-mongoose-es6-rest-api-production',
port: 3000
env: 'production',
db: 'mongodb://localhost/express-mongoose-es6-rest-api-production',
port: 3000
};
View
@@ -1,5 +1,5 @@
export default {
env: 'test',
db: 'mongodb://localhost/express-mongoose-es6-rest-api-test',
port: 3000
env: 'test',
db: 'mongodb://localhost/express-mongoose-es6-rest-api-test',
port: 3000
};
View
@@ -17,7 +17,7 @@ import APIError from '../server/helpers/APIError';
const app = express();
if (config.env === 'development') {
app.use(logger('dev'));
app.use(logger('dev'));
}
// parse body params and attache them to req.body
@@ -36,52 +36,52 @@ app.use(cors());
// enable detailed API logging in dev env
if (config.env === 'development') {
expressWinston.requestWhitelist.push('body');
expressWinston.responseWhitelist.push('body');
app.use(expressWinston.logger({
winstonInstance,
meta: true, // optional: log meta data about request (defaults to true)
msg: 'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
colorStatus: true // Color the status code (default green, 3XX cyan, 4XX yellow, 5XX red).
}));
expressWinston.requestWhitelist.push('body');
expressWinston.responseWhitelist.push('body');
app.use(expressWinston.logger({
winstonInstance,
meta: true, // optional: log meta data about request (defaults to true)
msg: 'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
colorStatus: true // Color the status code (default green, 3XX cyan, 4XX yellow, 5XX red).
}));
}
// mount all routes on /api path
app.use('/api', routes);
// if error is not an instanceOf APIError, convert it.
app.use((err, req, res, next) => {
if (err instanceof expressValidation.ValidationError) {
// validation error contains errors which is an array of error each containing message[]
const unifiedErrorMessage = err.errors.map(error => error.messages.join('. ')).join(' and ');
const error = new APIError(unifiedErrorMessage, err.status, true);
return next(error);
} else if (!(err instanceof APIError)) {
const apiError = new APIError(err.message, err.status, err.isPublic);
return next(apiError);
}
return next(err);
if (err instanceof expressValidation.ValidationError) {
// validation error contains errors which is an array of error each containing message[]
const unifiedErrorMessage = err.errors.map(error => error.messages.join('. ')).join(' and ');
const error = new APIError(unifiedErrorMessage, err.status, true);
return next(error);
} else if (!(err instanceof APIError)) {
const apiError = new APIError(err.message, err.status, err.isPublic);
return next(apiError);
}
return next(err);
});
// catch 404 and forward to error handler
app.use((req, res, next) => {
const err = new APIError('API not found', httpStatus.NOT_FOUND);
return next(err);
const err = new APIError('API not found', httpStatus.NOT_FOUND);
return next(err);
});
// log error in winston transports except when executing test suite
if (config.env !== 'test') {
app.use(expressWinston.errorLogger({
winstonInstance
}));
app.use(expressWinston.errorLogger({
winstonInstance
}));
}
// error handler, send stacktrace only during development
app.use((err, req, res, next) => // eslint-disable-line no-unused-vars
res.status(err.status).json({
message: err.isPublic ? err.message : httpStatus[err.status],
stack: config.env === 'development' ? err.stack : {}
})
res.status(err.status).json({
message: err.isPublic ? err.message : httpStatus[err.status],
stack: config.env === 'development' ? err.stack : {}
})
);
export default app;
View
@@ -1,22 +1,22 @@
import Joi from 'joi';
export default {
// POST /api/users
createUser: {
body: {
username: Joi.string().required(),
mobileNumber: Joi.string().regex(/^[1-9][0-9]{9}$/).required()
}
},
// POST /api/users
createUser: {
body: {
username: Joi.string().required(),
mobileNumber: Joi.string().regex(/^[1-9][0-9]{9}$/).required()
}
},
// UPDATE /api/users/:userId
updateUser: {
body: {
username: Joi.string().required(),
mobileNumber: Joi.string().regex(/^[1-9][0-9]{9}$/).required()
},
params: {
userId: Joi.string().hex().required()
}
}
// UPDATE /api/users/:userId
updateUser: {
body: {
username: Joi.string().required(),
mobileNumber: Joi.string().regex(/^[1-9][0-9]{9}$/).required()
},
params: {
userId: Joi.string().hex().required()
}
}
};
View
@@ -1,12 +1,12 @@
import winston from 'winston';
const logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)({
json: true,
colorize: true
})
]
transports: [
new (winston.transports.Console)({
json: true,
colorize: true
})
]
});
export default logger;
Oops, something went wrong.

0 comments on commit 4ef4dac

Please sign in to comment.