-
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
1 parent
d4566ca
commit 513e740
Showing
54 changed files
with
2,962 additions
and
2,715 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 |
---|---|---|
@@ -1,42 +1,42 @@ | ||
/** | ||
* @file Contains all backend things for parches-chat application. | ||
* @author Manuel Cabral | ||
* @version 0.0.7 | ||
*/ | ||
|
||
// required modules | ||
const cors = require('cors') | ||
const morgan = require('morgan') | ||
const express = require('express') | ||
const compression = require('compression') | ||
const graphqlHTTP = require('express-graphql').graphqlHTTP | ||
const authenticate = require('./middlewares/auth') | ||
const schema = require('./graphql/schemas') | ||
|
||
// setting up | ||
const app = express() | ||
const logger = morgan('dev') | ||
|
||
// middlewares | ||
if (process.env.NODE_ENV?.trim() === 'development') app.use(logger) | ||
app.use(cors()) | ||
app.use(compression()) | ||
app.use(authenticate) | ||
|
||
// routes | ||
app.get('/', (_, res) => { | ||
res.send('Hello World') | ||
}) | ||
|
||
app.use( | ||
'/graphql', | ||
graphqlHTTP({ | ||
schema: schema, | ||
graphiql: { | ||
subscriptionEndpoint: `ws://localhost:4000/subscriptions`, | ||
websocketClient: 'v1', | ||
}, | ||
}) | ||
) | ||
|
||
module.exports = app | ||
/** | ||
* @file Contains all backend things for parches-chat application. | ||
* @author Manuel Cabral | ||
* @version 0.0.7 | ||
*/ | ||
|
||
// required modules | ||
const cors = require('cors') | ||
const morgan = require('morgan') | ||
const express = require('express') | ||
const compression = require('compression') | ||
const graphqlHTTP = require('express-graphql').graphqlHTTP | ||
const authenticate = require('./middlewares/auth') | ||
const schema = require('./graphql/schemas') | ||
|
||
// setting up | ||
const app = express() | ||
const logger = morgan('dev') | ||
|
||
// middlewares | ||
if (process.env.NODE_ENV.trim() === 'development') app.use(logger) | ||
app.use(cors()) | ||
app.use(compression()) | ||
app.use(authenticate) | ||
|
||
// routes | ||
app.get('/', (_, res) => { | ||
res.send('Hello World') | ||
}) | ||
|
||
app.use( | ||
'/graphql', | ||
graphqlHTTP({ | ||
schema: schema, | ||
graphiql: { | ||
subscriptionEndpoint: `ws://localhost:4000/subscriptions`, | ||
websocketClient: 'v1', | ||
}, | ||
}) | ||
) | ||
|
||
module.exports = app |
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,50 +1,50 @@ | ||
/** | ||
* @file Contains environment variables and some configuration. | ||
* @author Manuel Cabral | ||
* @version 0.0.8 | ||
*/ | ||
|
||
const config = require('dotenv').config | ||
|
||
// load environment variables | ||
config() | ||
|
||
// export configuration | ||
module.exports = { | ||
// server port | ||
PORT: process.env.PORT || 4000, | ||
|
||
// database connection | ||
DB: { | ||
URL: process.env.MONGODB_URL || 'mongodb://localhost/parches-chat', | ||
OPTIONS: { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true, | ||
useCreateIndex: true, | ||
useFindAndModify: false, | ||
}, | ||
}, | ||
|
||
// cloudinary | ||
CLOUDINARY: { | ||
CLOUD_NAME: process.env.CLOUDINARY_CLOUD_NAME, | ||
API_KEY: process.env.CLOUDINARY_API_KEY, | ||
API_SECRET: process.env.CLOUDINARY_API_SECRET, | ||
FOLDER: process.env.CLOUDINARY_FOLDER, | ||
}, | ||
|
||
// json web token | ||
JWT: { | ||
SECRET: process.env.JWT_SECRET || 'supersecret', | ||
EXPIRES_IN: process.env.JWT_EXPIRES_IN || '1d', | ||
EMAIL_SECRET: process.env.JWT_EMAIL_SECRET || 'emailsecret', | ||
EMAIL_EXPIRES_IN: process.env.JWT_EMAIL_EXPIRES_IN || '5m', | ||
}, | ||
|
||
EMAIL: { | ||
USER: process.env.EMAIL_USER, | ||
PASSWORD: process.env.EMAIL_PASS, | ||
ADDRESS: process.env.EMAIL, | ||
}, | ||
} | ||
/** | ||
* @file Contains environment variables and some configuration. | ||
* @author Manuel Cabral | ||
* @version 0.0.8 | ||
*/ | ||
|
||
const config = require('dotenv').config | ||
|
||
// load environment variables | ||
config() | ||
|
||
// export configuration | ||
module.exports = { | ||
// server port | ||
PORT: process.env.PORT || 4000, | ||
|
||
// database connection | ||
DB: { | ||
URL: process.env.MONGODB_URL || 'mongodb://localhost/parches-chat', | ||
OPTIONS: { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true, | ||
useCreateIndex: true, | ||
useFindAndModify: false, | ||
}, | ||
}, | ||
|
||
// cloudinary | ||
CLOUDINARY: { | ||
CLOUD_NAME: process.env.CLOUDINARY_CLOUD_NAME, | ||
API_KEY: process.env.CLOUDINARY_API_KEY, | ||
API_SECRET: process.env.CLOUDINARY_API_SECRET, | ||
FOLDER: process.env.CLOUDINARY_FOLDER, | ||
}, | ||
|
||
// json web token | ||
JWT: { | ||
SECRET: process.env.JWT_SECRET || 'supersecret', | ||
EXPIRES_IN: process.env.JWT_EXPIRES_IN || '1d', | ||
EMAIL_SECRET: process.env.JWT_EMAIL_SECRET || 'emailsecret', | ||
EMAIL_EXPIRES_IN: process.env.JWT_EMAIL_EXPIRES_IN || '5m', | ||
}, | ||
|
||
EMAIL: { | ||
USER: process.env.EMAIL_USER, | ||
PASSWORD: process.env.EMAIL_PASS, | ||
ADDRESS: process.env.EMAIL, | ||
}, | ||
} |
Oops, something went wrong.