File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Write and Deploy Chat Application Frontend and Backend
22
3+ ### To start the program
4+
5+ First install dependencies:
6+
7+ ``` bash
8+ npm install
9+ ```
10+
11+ From ` /backend ` directory:
12+
13+ Option 1. Production mode
14+
15+ ``` bash
16+ npm start
17+ ```
18+
19+ Option 2. Development mode
20+
21+ ``` bash
22+ npm run dev
23+ ```
24+
325### Link to the coursework
426
527https://sdc.codeyourfuture.io/decomposition/sprints/2/prep/
Original file line number Diff line number Diff line change 11import express from "express" ;
22import cors from "cors" ;
3+ import dotenv from "dotenv" ;
34
45const app = express ( ) ;
56app . use ( cors ( ) ) ;
67app . use ( express . json ( ) ) ;
8+ app . use ( dotenv ( ) )
79
8- const port = 3000 ;
10+ const port = process . env . PORT || 3000 ;
911let nextMessageId = 1 ;
1012const messages = [
1113 {
Original file line number Diff line number Diff line change 88 "main" : " index.js" ,
99 "scripts" : {
1010 "test" : " echo \" Error: no test specified\" && exit 1" ,
11- "start" : " nodemon ./index.js"
11+ "start" : " node index.js" ,
12+ "dev" : " nodemon index.js"
1213 },
1314 "dependencies" : {
1415 "cors" : " ^2.8.6" ,
16+ "dotenv" : " ^17.4.2" ,
1517 "express" : " ^5.2.1"
1618 },
1719 "devDependencies" : {
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ let messageEl = document.getElementById("message");
55let displayBox = document . getElementById ( "display-message" ) ;
66let feedbackEl = document . getElementById ( "feedback" ) ;
77
8- // const serverURL = `https://janefrancessc-chat-application-backend.hosting.codeyourfuture.io/messages`;
9- const serverURL = "http://127.0.0.1:3000/messages" ;
8+ const serverURL = `https://janefrancessc-chat-application-backend.hosting.codeyourfuture.io/messages` ;
9+ // const serverURL = "http://127.0.0.1:3000/messages";
1010const state = { messages : [ ] } ;
1111let pollingMode = "regular" ;
1212let longPoll = false ;
You can’t perform that action at this time.
0 commit comments