Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IFREPAIRS_FINAL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
65160111
IFREPAIRS_FINAL
Commits
3147dd57
Commit
3147dd57
authored
2 weeks ago
by
65160111
Browse files
Options
Downloads
Patches
Plain Diff
Update env.port
parent
c0763a49
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.env
+1
-1
1 addition, 1 deletion
.env
routes/reports.js
+20
-19
20 additions, 19 deletions
routes/reports.js
server.js
+2
-1
2 additions, 1 deletion
server.js
with
23 additions
and
21 deletions
.env
+
1
−
1
View file @
3147dd57
PORT=
3306
PORT=
8080
DB_HOST=10.104.20.255
DB_USER=root
DB_PASS=OAOsac27273
...
...
This diff is collapsed.
Click to expand it.
routes/reports.js
+
20
−
19
View file @
3147dd57
...
...
@@ -89,25 +89,26 @@ router.get("/", authMiddleware, (req, res) => {
// 🔹 Get Single Report by ID
router
.
get
(
"
/:id
"
,
authMiddleware
,
(
req
,
res
)
=>
{
db
.
query
(
`
SELECT reports.*, users.username, rooms.room_name
FROM reports
JOIN users ON reports.user_id = users.id
JOIN rooms ON reports.room_id = rooms.id
WHERE reports.id = ?`
,
[
req
.
params
.
id
],
(
err
,
results
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
.
message
});
if
(
results
.
length
===
0
)
return
res
.
status
(
404
).
json
({
error
:
"
Report Not Found
"
});
const
report
=
results
[
0
];
if
(
report
.
image_url
)
{
report
.
image_url
=
`http://localhost:8080
${
report
.
image_url
}
`
;
}
res
.
json
(
report
);
});
});
db
.
query
(
`
SELECT reports.*, users.username, rooms.room_name, rooms.floor
FROM reports
JOIN users ON reports.user_id = users.id
JOIN rooms ON reports.room_id = rooms.id
WHERE reports.id = ?`
,
[
req
.
params
.
id
],
(
err
,
results
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
.
message
});
if
(
results
.
length
===
0
)
return
res
.
status
(
404
).
json
({
error
:
"
Report Not Found
"
});
const
report
=
results
[
0
];
if
(
report
.
image_url
)
{
// ลบช่องว่างที่ไม่จำเป็นออก
report
.
image_url
=
`http://localhost:8080
${
report
.
image_url
}
`
;
}
res
.
json
(
report
);
});
});
// 🔹 Update Report (แก้ไขเฉพาะ Title, Description)
router
.
put
(
"
/:id
"
,
authMiddleware
,
(
req
,
res
)
=>
{
...
...
This diff is collapsed.
Click to expand it.
server.js
+
2
−
1
View file @
3147dd57
...
...
@@ -21,5 +21,6 @@ app.use("/api/reports", require("./routes/reports"));
app
.
use
(
"
/uploads
"
,
express
.
static
(
"
uploads
"
));
// 📌 กำหนด PORT
const
PORT
=
8080
;
const
PORT
=
process
.
env
.
PORT
||
8080
;
app
.
listen
(
PORT
,
()
=>
console
.
log
(
`🚀 Server running on port
${
PORT
}
`
));
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment