Skip to content

Commit

Permalink
Update codebase to latest patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Reis committed Dec 9, 2016
1 parent aa7590b commit 2191d2a
Show file tree
Hide file tree
Showing 91 changed files with 6,512 additions and 1,190 deletions.
12 changes: 10 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@ max_line_length = 80
insert_final_newline = true
trim_trailing_whitespace = true

# JS
[{*.js}]
# HTML
[*.html]
max_line_length = 120

# JS/JSON
[*.{js,json}]
quote_type = single
curly_bracket_next_line = false
spaces_around_operators = true
space_after_control_statements = true
space_after_anonymous_functions = false
spaces_in_brackets = false

# YAML
[*.yaml]
trim_trailing_whitespace = false
5 changes: 5 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ rules:
no-multiple-empty-lines:
- error
- max: 1
no-global-assign:
- error
- exceptions:
- Promise
eol-last: error
dot-notation: error
space-infix-ops: error
Expand All @@ -135,6 +139,7 @@ rules:
no-mixed-spaces-and-tabs: error
no-spaced-func: error
no-whitespace-before-property: error
no-unsafe-negation: error
no-lonely-if: error
no-var: error
no-console: off
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
message = "[bump] server@%s"
message = "%s"
git-tag-version = false
14 changes: 0 additions & 14 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The MIT License (MIT)

Copyright (c) 2016 Adam Buczynski
Copyright (c) 2016 Adam Reis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: node scripts/server.js
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ Pull requests are welcome! If you would like to contribute to Meanie, please che

(MIT License)

Copyright 2015-2016, [Adam Buczynski](http://adambuczynski.com)
Copyright 2015-2017, [Adam Reis](http://adam.reis.nz)
9 changes: 0 additions & 9 deletions app.yaml

This file was deleted.

55 changes: 35 additions & 20 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@
/**
* Dependencies
*/
let path = require('path');
let i18n = require('i18n');
let cors = require('cors');
let morgan = require('morgan');
let express = require('express');
let bodyParser = require('body-parser');
let compression = require('compression');
let serveStatic = require('serve-static');
let cookieParser = require('cookie-parser');
let errors = require('meanie-express-error-handling');
let jwt = require('meanie-express-jwt-service');
let router = require('./services/router');
let db = require('./services/db');
let auth = require('./services/auth');
let config = require('./config');
const i18n = require('i18n');
const cors = require('cors');
const morgan = require('morgan');
const express = require('express');
const bodyParser = require('body-parser');
const compression = require('compression');
const cookieParser = require('cookie-parser');
const errors = require('meanie-express-error-handling');
const raven = require('meanie-express-raven-service');
const jwt = require('meanie-express-jwt-service');
const router = require('./services/router');
const db = require('./services/db');
const auth = require('./services/auth');
const config = require('./config');

/**
* Configuration
*/
const ENV = config.ENV;
const APP_VERSION = config.APP_VERSION;
const CORS_ORIGINS = config.CORS_ORIGINS;
const I18N_LOCALES = config.I18N_LOCALES;
const I18N_DEFAULT_LOCALE = config.I18N_DEFAULT_LOCALE;
Expand All @@ -31,8 +32,20 @@ const TOKEN_DEFAULT_AUDIENCE = config.TOKEN_DEFAULT_AUDIENCE;
const SERVER_LATENCY = config.SERVER_LATENCY;
const SERVER_LATENCY_MIN = config.SERVER_LATENCY_MIN;
const SERVER_LATENCY_MAX = config.SERVER_LATENCY_MAX;
const SENTRY_DSN = config.SENTRY_DSN;
const SENTRY_CONFIG = config.SENTRY_CONFIG;
const ERROR_MIDDLEWARE = config.ERROR_MIDDLEWARE;

//Increase stack trace limit for non production environments
if (ENV !== 'production') {
Error.stackTraceLimit = Infinity;
}

//Use sentry
if (SENTRY_DSN) {
raven(SENTRY_DSN, SENTRY_CONFIG);
}

//Configure i18n
i18n.configure({
directory: 'app/locales',
Expand Down Expand Up @@ -96,10 +109,6 @@ module.exports = function() {
//Use i18n
app.use(i18n.init);

//Set static folders
app.use(serveStatic(path.resolve('./public')));
app.use(serveStatic(path.resolve('./data')));

//Simulate latency
if (SERVER_LATENCY) {
let latency = require('express-simulate-latency')({
Expand All @@ -112,12 +121,18 @@ module.exports = function() {
//Load authentication
auth(app);

//Set global headers
app.all('/*', (req, res, next) => {
res.header('X-Version', APP_VERSION);
next();
});

//Load router
router(app);

//Create error handling middleware stack
errors
.middleware(ERROR_MIDDLEWARE.concat(['auth-clear-cookie', 'send']))
.middleware(ERROR_MIDDLEWARE.concat(['send']))
.forEach(handler => app.use(handler));

//Return express server instance
Expand Down
Loading

0 comments on commit 2191d2a

Please sign in to comment.