start through npm start implemented
This commit is contained in:
1 parent
8b2dc0b52e
commit
e93dc88619
5 files changed
+4686
-7
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
|
||||
client/node_modules/*
|
||||
server/node_modules/*
|
||||
client/src/auth/Auth0.js
|
||||
server/auth/Auth0.js
|
||||
server/models/MongoDB.js
|
||||
server/.env
|
||||
+6
-3
@@ -1,6 +1,8 @@
|
||||
|
||||
/* This module imports */
|
||||
|
||||
require('dotenv/config')
|
||||
import logger from './config/logger'
|
||||
const globals = require('./globals')
|
||||
const sessions = require('./sessions')
|
||||
const express = require('express')
|
||||
@@ -17,10 +19,11 @@ const app = express()
|
||||
// Allow crosss-origin requests
|
||||
app.use(cors())
|
||||
|
||||
// Connect to the database
|
||||
mongoose.connect(mongodbConfig.connectionString, { useNewUrlParser: true })
|
||||
// Database Connection
|
||||
mongoose.connect(`mongodb://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@${process.env.DB_DOMAIN}`, { useNewUrlParser: true })
|
||||
|
||||
mongoose.connection.once('open', () => {
|
||||
console.log('Connected to Mongo')
|
||||
logger.info('Connected to the DB.')
|
||||
})
|
||||
|
||||
/* Here we bind all requests to this endpoint to be procecced by the GraphQL Library. */
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { createLogger, format, transports } from 'winston'
|
||||
const { combine, timestamp, simple } = format
|
||||
import { inspect } from 'util'
|
||||
|
||||
const options = {
|
||||
file: {
|
||||
level: 'info',
|
||||
filename: '../logs/app.log',
|
||||
handleExceptions: true,
|
||||
json: true,
|
||||
maxsize: 5242880, // 5MB
|
||||
maxFiles: 5,
|
||||
colorize: false,
|
||||
timestamp: true
|
||||
},
|
||||
console: {
|
||||
level: 'debug',
|
||||
handleExceptions: true,
|
||||
json: false,
|
||||
colorize: true,
|
||||
timestamp: true
|
||||
}
|
||||
}
|
||||
|
||||
const logger = createLogger({
|
||||
level: 'info',
|
||||
format: format.combine(
|
||||
format.colorize(),
|
||||
format.timestamp({ format: 'YY/MM/DD HH:mm' }),
|
||||
format.printf(
|
||||
info => `${info.timestamp} - ${info.level}: ${JSON.parse(JSON.stringify(inspect(info.message)))}`
|
||||
)
|
||||
),
|
||||
transports: [
|
||||
new transports.File(options.file),
|
||||
new transports.Console(options.console)
|
||||
],
|
||||
exitOnError: false // do not exit on handled exceptions
|
||||
})
|
||||
|
||||
export default logger
|
||||
Generated
+4626
File diff suppressed because it is too large.
Load diff
+12
-3
@@ -1,15 +1,23 @@
|
||||
{
|
||||
"name": "server",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"description": "Advanced Algos Users backend API",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"start": "nodemon --exec babel-node --presets env,stage-2 app.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-preset-env": "^1.7.0",
|
||||
"babel-preset-stage-2": "^6.24.1",
|
||||
"nodemon": "^1.18.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"cors": "^2.8.4",
|
||||
"dotenv": "^6.0.0",
|
||||
"express": "^4.16.3",
|
||||
"express-graphql": "^0.6.12",
|
||||
"express-jwt": "^5.3.1",
|
||||
@@ -17,6 +25,7 @@
|
||||
"jsonwebtoken": "^8.3.0",
|
||||
"jwks-rsa": "^1.3.0",
|
||||
"lodash": "^4.17.10",
|
||||
"mongoose": "^5.2.12"
|
||||
"mongoose": "^5.2.12",
|
||||
"winston": "^3.1.0"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user