Skip to content

Commit 89315d3

Browse files
committed
fix: rename generate access token
1 parent 7548086 commit 89315d3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/scripts/generateEnvJWT.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ const getUniqueCodev2 = (length = 32) => {
1212
return result
1313
}
1414

15-
function main() {
15+
function accessTokenJWT() {
1616
const pathRes = path.resolve('.env')
1717
const contentEnv = fs.readFileSync(pathRes, { encoding: 'utf-8' })
1818
const jwtSecret = getUniqueCodev2()
19-
const strJWT = `JWT_SECRET=${jwtSecret}`
19+
const strJWT = `JWT_SECRET_ACCESS_TOKEN=${jwtSecret}`
2020

21-
if (contentEnv.includes('JWT_SECRET=')) {
21+
if (contentEnv.includes('JWT_SECRET_ACCESS_TOKEN=')) {
2222
// Replace JWT SECRET jika sudah ada
23-
const replaceContent = contentEnv.replace(/JWT_SECRET=(.*)?/, strJWT)
23+
const replaceContent = contentEnv.replace(
24+
/JWT_SECRET_ACCESS_TOKEN=(.*)?/,
25+
strJWT
26+
)
2427
fs.writeFileSync(`${pathRes}`, replaceContent)
2528
console.log('Refresh JWT SECRET Success')
2629
} else {
@@ -53,5 +56,5 @@ function refreshTokenJWT() {
5356
}
5457
}
5558

56-
main()
59+
accessTokenJWT()
5760
refreshTokenJWT()

0 commit comments

Comments
 (0)