Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
corps-directory
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fhurtado14
corps-directory
Commits
47a017de
Commit
47a017de
authored
5 months ago
by
Federico Luis Hurtado
Browse files
Options
Downloads
Patches
Plain Diff
establish connection to database.
parent
69e7e379
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Dockerfile
+1
-1
1 addition, 1 deletion
Dockerfile
index.js
+29
-0
29 additions, 0 deletions
index.js
with
30 additions
and
1 deletion
Dockerfile
+
1
−
1
View file @
47a017de
...
...
@@ -5,7 +5,7 @@ FROM node:14
WORKDIR
/app
# Copy package.json and install dependencies
COPY
package.json /app
COPY
package
*
.json /app
RUN
npm
install
...
...
This diff is collapsed.
Click to expand it.
index.js
+
29
−
0
View file @
47a017de
const
express
=
require
(
'
express
'
);
const
mysql
=
require
(
'
mysql2
'
);
const
app
=
express
();
app
.
use
(
express
.
json
())
// MySQL Database connection setup
const
db
=
mysql
.
createConnection
({
host
:
'
mariadb
'
,
user
:
'
corps-directory-dev
'
,
password
:
'
corps-password
'
,
database
:
'
corps-directory-db
'
});
// Connect to the database
db
.
connect
(
err
=>
{
if
(
err
)
{
console
.
error
(
'
Error connecting to MySQL:
'
,
err
);
return
;
}
console
.
log
(
'
Connected to MySQL
'
);
});
const
port
=
process
.
env
.
PORT
||
3000
;
app
.
get
(
'
/
'
,
(
req
,
res
)
=>
{
res
.
send
(
'
Hello World!
'
);
});
...
...
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