Skip to content

Commit 2317e81

Browse files
committed
readme updated
1 parent 19c4a0c commit 2317e81

File tree

1 file changed

+34
-42
lines changed

1 file changed

+34
-42
lines changed

README.md

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ node -v
3535
npm -v
3636
```
3737

38-
02. **Create a Project Folder**:
39-
40-
38+
2. **Create a Project Folder**:
4139

4240
```powershell
4341
mkdir my-node-project
@@ -76,66 +74,60 @@ _Express.js_ is a framework that simplifies building Node.js backend application
7674
1. **Create `server.js`**: The entry point of your application [1].
7775

7876
```javascript
79-
const express = require('express');
80-
const app = express();
81-
82-
app.get('/', (req, res) => {
83-
res.send('<h1>Hello, Express.js Server!</h1>');
84-
});
85-
86-
const port = 3000;
87-
app.listen(port, () => {
88-
console.log(`Server is running on port ${port}`);
89-
});
90-
```
77+
const express = require("express");
78+
const app = express();
9179

92-
02. **Run Your Server**:
80+
app.get("/", (req, res) => {
81+
res.send("<h1>Hello, Express.js Server!</h1>");
82+
});
9383

84+
const port = 3000;
85+
app.listen(port, () => {
86+
console.log(`Server is running on port ${port}`);
87+
});
88+
```
9489

90+
2. **Run Your Server**:
9591

92+
```powershell
93+
node server.js
9694
```
9795

98-
node server.js
99-
```
100-
10196
3. **Define Routes**: How your server responds to different URL requests [2].
10297

10398
```javascript
104-
app.get('/about', (req, res) => {
105-
res.send('This is the about page');
106-
});
107-
108-
app.get('/contact', (req, res) => {
109-
res.send('This is the contact page');
110-
});
111-
```
112-
113-
Use `nodemon` for automatic server restarts:
99+
app.get("/about", (req, res) => {
100+
res.send("This is the about page");
101+
});
114102

103+
app.get("/contact", (req, res) => {
104+
res.send("This is the contact page");
105+
});
106+
```
115107

108+
Use `nodemon` for automatic server restarts:
116109

110+
```powershell
111+
npm install -g nodemon
112+
nodemon server.js
117113
```
118114

119-
npm install -g nodemon
120-
nodemon server.js
121-
```
122-
123115
## **Proxy and CORS in Vite**
124116

125117
_Vite_ is a build tool that improves the front-end development experience. Configuring a proxy in `vite.config.js` is essential for redirecting API calls during development [3].
126118

127119
```javascript
128120

129121
export default defineConfig({
130-
server: {
131-
proxy: {
132-
'/api': {
133-
target: 'http://localhost:3000',
134-
changeOrigin: true,
135-
rewrite: (path) => path.replace(/^/api/, ''),
136-
},
137-
},
138-
},
122+
server: {
123+
proxy: {
124+
'/api': {
125+
target: 'http://localhost:3000',
126+
changeOrigin: true,
127+
rewrite: (path) => path.replace(/^/api/, ''),
128+
},
129+
},
130+
},
139131
});
140132
```
141133

0 commit comments

Comments
 (0)