Skip to content

Commit

Permalink
- quick fix to hopefully fix hosting issues on Railway
Browse files Browse the repository at this point in the history
- added configuration for Railway
- other changes are still being worked on, so I decided to withold all of them to ensure successful deployment.
  • Loading branch information
latekvo committed Sep 19, 2023
1 parent 22f675c commit 626558c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
12 changes: 12 additions & 0 deletions railway.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "npm install && ng build --configuration development"
},
"deploy": {
"numReplicas": 1,
"startCommand": "node src/server.js",
"restartPolicyType": "NEVER"
}
}
2 changes: 1 addition & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const databaseStarter = require('./src/databaseStarter');
const databaseService = require('./src/databaseService');
const apiRouter = require('./src/apiCalls');

const port = process.env.NODE_PORT || 3000;
const port = process.env.PORT || process.env.NODE_PORT || 3000;

const rootPath = path.join(__dirname, '..', 'dist', 'angular-messenger');

Expand Down
6 changes: 3 additions & 3 deletions src/src/apiCalls.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function verifyRequest(req, res, requiredValues = []) {
let sanitize = (input) => {
// https://stackoverflow.com/questions/2794137/sanitizing-user-input-before-adding-it-to-the-dom-in-javascript
const map = {
'&': '&',
//'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
Expand Down Expand Up @@ -231,7 +231,7 @@ router.post('/sendMessage', (req, res) => {
if (output?.id) {
let messageInsertionQuery = {
dateCreated: newSqlDate(),
userId: userId,
senderId: userId,
chatId: messageChatId,
content: messageContent
};
Expand All @@ -240,7 +240,7 @@ router.post('/sendMessage', (req, res) => {
let broadCastedMessage = {
id: messageId,
dateCreated: newSqlDate(), // more readable for now
userId: userId,
senderId: userId,
content: messageContent
}
broadcastMessage(messageChatId, broadCastedMessage);
Expand Down
2 changes: 1 addition & 1 deletion src/src/databaseStarter.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ CREATE TABLE IF NOT EXISTS messages (
chatId TEXT,
content TEXT,
FOREIGN KEY(userId) REFERENCES users(id),
FOREIGN KEY(senderId) REFERENCES users(id),
FOREIGN KEY(chatId) REFERENCES chats(id)
);
Expand Down

0 comments on commit 626558c

Please sign in to comment.