Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
BACKEND CHALLENGES
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Phạm Quang Bảo
BACKEND CHALLENGES
Commits
2b766521
Commit
2b766521
authored
May 25, 2026
by
Phạm Quang Bảo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: deploy render
parent
21924786
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
12 deletions
+65
-12
.env.example
backend/.env.example
+8
-3
sequelize-config.ts
backend/src/models/sequelize-config.ts
+26
-4
user_auth.ts
backend/src/models/user_auth.ts
+2
-1
database-gen.ts
backend/src/scripts/database-gen.ts
+26
-4
init.sql
database/init.sql
+3
-0
No files found.
backend/.env.example
View file @
2b766521
EMAIL_USER = abc@gmail.com
EMAIL_USER = abc@gmail.com
EMAIL_PASS = 1234 5678 9012 3456
EMAIL_PASS = password
JWT_SECRET = 0987654321
JWT_SECRET = secretkey
\ No newline at end of file
HOSTNAMEDB = localhost
PORTDB = 5432
NAMEDB = mydatabase
USERNAMEDB = myuser
PASSWORDDB = example
\ No newline at end of file
backend/src/models/sequelize-config.ts
View file @
2b766521
import
{
Sequelize
}
from
'sequelize'
;
import
{
Sequelize
}
from
'sequelize'
;
import
{
config
as
loadEnv
}
from
'dotenv'
;
import
{
initModels
}
from
'#models/init-models.js'
;
import
{
initModels
}
from
'#models/init-models.js'
;
const
sequelize
=
new
Sequelize
(
'challenge_db'
,
'postgres'
,
'123456'
,
{
loadEnv
({
override
:
true
});
host
:
'localhost'
,
port
:
2550
,
const
host
=
process
.
env
.
HOSTNAMEDB
||
'localhost'
;
const
useSsl
=
process
.
env
.
DB_SSL
===
'true'
||
host
.
includes
(
'render.com'
);
const
sequelizeOptions
:
Record
<
string
,
unknown
>
=
{
host
,
port
:
Number
(
process
.
env
.
PORTDB
)
||
2550
,
dialect
:
'postgres'
,
dialect
:
'postgres'
,
logging
:
false
,
logging
:
false
,
define
:
{
define
:
{
underscored
:
true
,
underscored
:
true
,
timestamps
:
false
,
timestamps
:
false
,
},
},
});
};
if
(
useSsl
)
{
sequelizeOptions
.
dialectOptions
=
{
ssl
:
{
require
:
true
,
rejectUnauthorized
:
false
,
},
};
}
const
sequelize
=
new
Sequelize
(
process
.
env
.
NAMEDB
||
'mydatabase'
,
process
.
env
.
USERNAMEDB
||
'myuser'
,
process
.
env
.
PASSWORDDB
||
'example'
,
sequelizeOptions
as
any
,
);
const
models
=
initModels
(
sequelize
);
const
models
=
initModels
(
sequelize
);
...
...
backend/src/models/user_auth.ts
View file @
2b766521
...
@@ -67,7 +67,8 @@ export class user_auth extends Model<user_authAttributes, user_authCreationAttri
...
@@ -67,7 +67,8 @@ export class user_auth extends Model<user_authAttributes, user_authCreationAttri
},
},
active
:
{
active
:
{
type
:
DataTypes
.
BOOLEAN
,
type
:
DataTypes
.
BOOLEAN
,
allowNull
:
true
allowNull
:
true
,
defaultValue
:
false
}
}
},
{
},
{
tableName
:
'user_auth'
,
tableName
:
'user_auth'
,
...
...
backend/src/scripts/database-gen.ts
View file @
2b766521
import
{
config
as
loadEnv
}
from
'dotenv'
;
import
SequelizeAuto
from
'sequelize-auto'
;
import
SequelizeAuto
from
'sequelize-auto'
;
const
auto
=
new
SequelizeAuto
(
'challenge_db'
,
'postgres'
,
'123456'
,
{
loadEnv
({
override
:
true
});
host
:
'localhost'
,
port
:
2550
,
const
host
=
process
.
env
.
HOSTNAMEDB
||
'localhost'
;
const
useSsl
=
process
.
env
.
DB_SSL
===
'true'
||
host
.
includes
(
'render.com'
);
const
autoOptions
:
any
=
{
host
,
port
:
Number
(
process
.
env
.
PORTDB
)
||
2550
,
dialect
:
'postgres'
,
dialect
:
'postgres'
,
directory
:
'./src/models'
,
directory
:
'./src/models'
,
lang
:
'ts'
,
lang
:
'ts'
,
...
@@ -15,7 +21,23 @@ const auto = new SequelizeAuto('challenge_db', 'postgres', '123456', {
...
@@ -15,7 +21,23 @@ const auto = new SequelizeAuto('challenge_db', 'postgres', '123456', {
additional
:
{
additional
:
{
timestamps
:
false
,
timestamps
:
false
,
},
},
});
};
if
(
useSsl
)
{
autoOptions
.
dialectOptions
=
{
ssl
:
{
require
:
true
,
rejectUnauthorized
:
false
,
},
};
}
const
auto
=
new
SequelizeAuto
(
process
.
env
.
NAMEDB
||
'mydatabase'
,
process
.
env
.
USERNAMEDB
||
'myuser'
,
process
.
env
.
PASSWORDDB
||
'example'
,
autoOptions
,
);
console
.
log
(
'🔄 Đang tiến hành quét Database và sinh Model...'
);
console
.
log
(
'🔄 Đang tiến hành quét Database và sinh Model...'
);
...
...
database/init.sql
View file @
2b766521
...
@@ -39,6 +39,9 @@ CREATE TABLE user_auth (
...
@@ -39,6 +39,9 @@ CREATE TABLE user_auth (
id
uuid
DEFAULT
gen_random_uuid
()
NOT
NULL
,
id
uuid
DEFAULT
gen_random_uuid
()
NOT
NULL
,
user_id
uuid
,
user_id
uuid
,
password_hash
text
,
password_hash
text
,
otp_code
VARCHAR
(
6
),
otp_expiry
TIMESTAMP
WITH
TIME
ZONE
,
active
BOOLEAN
DEFAULT
false
,
created_at
timestamp
with
time
zone
DEFAULT
now
()
created_at
timestamp
with
time
zone
DEFAULT
now
()
);
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment