-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
9,933 additions
and
1,103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", { | ||
"targets": { | ||
"node": "current" | ||
} | ||
} | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"root": true, | ||
"extends": "airbnb-base", | ||
"env": { | ||
"node": true, | ||
"es6": true, | ||
"mocha": true | ||
}, | ||
"rules": { | ||
"one-var": 0, | ||
"one-var-declaration-per-line": 0, | ||
"new-cap": 0, | ||
"consistent-return": 0, | ||
"no-param-reassign": 0, | ||
"comma-dangle": 0, | ||
"curly": ["error", "multi-line"], | ||
"import/no-unresolved": [2, { "commonjs": true }], | ||
"no-shadow": ["error", { "allow": ["req", "res", "err"] }], | ||
"valid-jsdoc": ["error", { | ||
"requireReturn": true, | ||
"requireReturnType": true, | ||
"requireParamDescription": false, | ||
"requireReturnDescription": true | ||
}], | ||
"require-jsdoc": ["error", { | ||
"require": { | ||
"FunctionDeclaration": true, | ||
"MethodDefinition": true, | ||
"ClassDeclaration": true | ||
} | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
eslint: | ||
enabled: true | ||
config_file: .eslintrc.json | ||
ignore_file: .eslintignore.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
"config": path.resolve('./server/config', 'config.js'), | ||
"models-path": path.resolve('./server/models'), | ||
"seeders-path": path.resolve('./server/seeders'), | ||
"migrations-path": path.resolve('./server/migrations') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- "11.6.0" | ||
|
||
after_success: npm run coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module.exports = { | ||
secret: | ||
process.env.NODE_ENV === "production" ? process.env.SECRET : "secret" | ||
}; | ||
// module.exports = { | ||
// secret: | ||
// process.env.NODE_ENV === 'production' ? process.env.SECRET : 'secret' | ||
// }; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,51 @@ | ||
const fs = require("fs"), | ||
http = require("http"), | ||
path = require("path"), | ||
methods = require("methods"), | ||
express = require("express"), | ||
bodyParser = require("body-parser"), | ||
session = require("express-session"), | ||
cors = require("cors"), | ||
passport = require("passport"), | ||
errorhandler = require("errorhandler"), | ||
mongoose = require("mongoose"); | ||
import express from 'express'; | ||
import bodyParser from 'body-parser'; | ||
import session from 'express-session'; | ||
import cors from 'cors'; | ||
import dotenv from 'dotenv'; | ||
import chalk from 'chalk'; | ||
import { createLogger, format, transports } from 'winston'; | ||
|
||
const logger = createLogger({ | ||
level: 'debug', | ||
format: format.simple(), | ||
transports: [new transports.Console()] | ||
}); | ||
|
||
const isProduction = process.env.NODE_ENV === "production"; | ||
dotenv.config(); | ||
|
||
const port = process.env.PORT || process.env.LOCAL_PORT; | ||
// Create global app object | ||
const app = express(); | ||
|
||
app.use(cors()); | ||
|
||
// Normal express config defaults | ||
app.use(require("morgan")("dev")); | ||
app.use(require('morgan')('dev')); | ||
|
||
app.use(bodyParser.urlencoded({ extended: false })); | ||
app.use(bodyParser.json()); | ||
|
||
app.use(require("method-override")()); | ||
app.use(express.static(__dirname + "/public")); | ||
app.use(require('method-override')()); | ||
|
||
app.use(express.static(`${__dirname}/public`)); | ||
|
||
app.use( | ||
session({ | ||
secret: "authorshaven", | ||
cookie: { maxAge: 60000 }, | ||
resave: false, | ||
saveUninitialized: false | ||
}) | ||
session({ | ||
secret: 'authorshaven', | ||
cookie: { maxAge: 60000 }, | ||
resave: false, | ||
saveUninitialized: false | ||
}) | ||
); | ||
|
||
if (!isProduction) { | ||
app.use(errorhandler()); | ||
} | ||
|
||
if (isProduction) { | ||
mongoose.connect(process.env.MONGODB_URI); | ||
} else { | ||
mongoose.connect("mongodb://localhost/conduit"); | ||
mongoose.set("debug", true); | ||
} | ||
app.get('/', (req, res) => res.status(200).send({ | ||
status: 'connection successful', | ||
message: 'Welcome to Author Haven!', | ||
})); | ||
|
||
require("./models/User"); | ||
|
||
app.use(require("./routes")); | ||
|
||
/// catch 404 and forward to error handler | ||
app.use(function(req, res, next) { | ||
const err = new Error("Not Found"); | ||
err.status = 404; | ||
next(err); | ||
app.listen(port, () => { | ||
logger.debug(`Server running on port ${chalk.blue(port)}`); | ||
}); | ||
|
||
/// error handlers | ||
|
||
// development error handler | ||
// will print stacktrace | ||
if (!isProduction) { | ||
app.use(function(err, req, res, next) { | ||
console.log(err.stack); | ||
|
||
res.status(err.status || 500); | ||
|
||
res.json({ | ||
errors: { | ||
message: err.message, | ||
error: err | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
// production error handler | ||
// no stacktraces leaked to user | ||
app.use(function(err, req, res, next) { | ||
res.status(err.status || 500); | ||
res.json({ | ||
errors: { | ||
message: err.message, | ||
error: {} | ||
} | ||
}); | ||
}); | ||
|
||
// finally, let's start our server... | ||
const server = app.listen(process.env.PORT || 3000, function() { | ||
console.log("Listening on port " + server.address().port); | ||
}); | ||
export default app; |
Oops, something went wrong.