Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MelonDeployFinal2
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
65160117
MelonDeployFinal2
Commits
fefe87d8
Commit
fefe87d8
authored
2 months ago
by
65160117
Browse files
Options
Downloads
Patches
Plain Diff
Edit server.js
parent
2a5f724b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.js
+19
-1
19 additions, 1 deletion
server.js
with
19 additions
and
1 deletion
server.js
+
19
−
1
View file @
fefe87d8
require
(
'
dotenv
'
).
config
();
require
(
'
dotenv
'
).
config
();
const
express
=
require
(
'
express
'
);
const
express
=
require
(
'
express
'
);
const
cors
=
require
(
'
cors
'
);
const
cors
=
require
(
'
cors
'
);
const
mysql
=
require
(
'
mysql2
'
);
const
bcrypt
=
require
(
'
bcrypt
'
);
const
bcrypt
=
require
(
'
bcrypt
'
);
const
jwt
=
require
(
'
jsonwebtoken
'
);
const
jwt
=
require
(
'
jsonwebtoken
'
);
const
path
=
require
(
'
path
'
);
const
path
=
require
(
'
path
'
);
const
multer
=
require
(
'
multer
'
);
const
multer
=
require
(
'
multer
'
);
const
fs
=
require
(
'
fs
'
);
const
fs
=
require
(
'
fs
'
);
const
db
=
require
(
'
./config/database
'
);
const
app
=
express
();
const
app
=
express
();
...
@@ -45,6 +45,24 @@ const upload = multer({
...
@@ -45,6 +45,24 @@ const upload = multer({
}
}
});
});
// เชื่อมต่อฐานข้อมูล
const
db
=
mysql
.
createConnection
({
host
:
process
.
env
.
DB_HOST
,
user
:
process
.
env
.
DB_USER
,
password
:
process
.
env
.
DB_PASSWORD
,
database
:
process
.
env
.
DB_NAME
,
port
:
process
.
env
.
DB_PORT
});
// ทดสอบการเชื่อมต่อฐานข้อมูล
db
.
connect
(
error
=>
{
if
(
error
)
{
console
.
error
(
'
Error connecting to the database:
'
,
error
);
return
;
}
console
.
log
(
"
Successfully connected to the database.
"
);
});
// Register
// Register
app
.
post
(
'
/register
'
,
async
(
req
,
res
)
=>
{
app
.
post
(
'
/register
'
,
async
(
req
,
res
)
=>
{
try
{
try
{
...
...
This diff is collapsed.
Click to expand it.
65160117
@65160117
mentioned in commit
29f5b14d
·
2 months ago
mentioned in commit
29f5b14d
mentioned in commit 29f5b14d925dd11ed910f6b06a111a574308b7aa
Toggle commit list
65160117
@65160117
mentioned in merge request
!1
·
2 months ago
mentioned in merge request
!1
mentioned in merge request !1
Toggle commit list
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