Skip to content

Commit

Permalink
For the three services, expressjs, XML_RPC, and Graphql, I have moved…
Browse files Browse the repository at this point in the history
… the port values to a centralised env file
  • Loading branch information
ds0 committed Aug 22, 2023
1 parent 33a366f commit d58c716
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
7 changes: 5 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
EXPRESS_JS_PORT=80
XML_RPC_PORT=9090
GRAPHQL_PORT=4000
JWT_SECRET=access
MONGO_LOCAL_CONN_URL=mongodb://localhost:27017/node-dvws
MONGO_DB_NAME=dvws-user-auth
SQL_LOCAL_CONN_URL=localhost
SQL_DB_NAME=dvws_sqldb
SQL_username=root
SQL_password=mysecretpassword
SQL_USERNAME=root
SQL_PASSWORD=mysecretpassword
8 changes: 4 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ app.use('/api', routes(router));



app.listen(80, () => {
console.log(`🚀 API listening at 80, go to http://dvws.local (127.0.0.1)`);
app.listen(process.env.EXPRESS_JS_PORT, () => {
console.log(`🚀 API listening at http://dvws.local${process.env.EXPRESS_JS_PORT == 80 ? "" : ":" + process.env.EXPRESS_JS_PORT } (127.0.0.1)`);
});


Expand All @@ -81,8 +81,8 @@ const server = new ApolloServer({
}, });


server.listen().then(({ url }) => {
server.listen({ port: process.env.GRAPHQL_PORT }).then(({ url }) => {
console.log(`🚀 GraphQL Server ready at ${url}`);
});;

module.exports = app;
module.exports = app;
4 changes: 2 additions & 2 deletions models/passphrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const Sequelize = require('sequelize');
require('dotenv').config();

const connHost = process.env.SQL_LOCAL_CONN_URL;
const connUser = process.env.SQL_username;
const connPass = process.env.SQL_password;
const connUser = process.env.SQL_USERNAME;
const connPass = process.env.SQL_PASSWORD;
const connDB = process.env.SQL_DB_NAME;

const sequelize = new Sequelize(connDB, connUser, connPass, {
Expand Down
4 changes: 2 additions & 2 deletions rpc_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var xmlrpc = require('xmlrpc');
var needle = require('needle');

// Creates an XML-RPC server to listen to XML-RPC method calls
var server = xmlrpc.createServer({ port: 9090, path: '/xmlrpc' })
var server = xmlrpc.createServer({ port: process.env.XML_RPC_PORT, path: '/xmlrpc' })
// Handle methods not found
server.on('NotFound', function (method, params) {
console.log('Method ' + method + ' does not exist');
Expand Down Expand Up @@ -44,5 +44,5 @@ server.on('dvws.CheckUptime', function (err, params, callback) {
callback(null, get_result)
})

console.log('XML-RPC server listening on port 9090')
console.log(`🚀 XML-RPC server listening on port ${process.env.XML_RPC_PORT}`)

4 changes: 2 additions & 2 deletions startup_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const User = require('./models/users');


const connHost = process.env.SQL_LOCAL_CONN_URL;
const connUser = process.env.SQL_username;
const connPass = process.env.SQL_password;
const connUser = process.env.SQL_USERNAME;
const connPass = process.env.SQL_PASSWORD;
const connUri = process.env.MONGO_LOCAL_CONN_URL;

const sequelize = new Sequelize('dvws_sqldb', connUser, connPass, {
Expand Down

0 comments on commit d58c716

Please sign in to comment.