-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from f-lab-edu/feature/66-typeorm-seed-problem
[#66] typeorm의 seed 라이브러리의 문제점
- Loading branch information
Showing
23 changed files
with
537 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[mysqld] | ||
innodb_stats_auto_recalc = 1 | ||
innodb_stats_persistent = 1 | ||
character-set-server = utf8mb4 | ||
collation-server = utf8mb4_unicode_ci | ||
|
||
[client] | ||
default-character-set = utf8mb4 | ||
|
||
[mysql] | ||
default-character-set = utf8mb4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,13 @@ | ||
import * as bcrypt from "bcrypt"; | ||
import jwt from "jsonwebtoken"; | ||
import { setSeederFactory } from "typeorm-extension"; | ||
|
||
import { ENV_JWT_SECRET_KEY } from "@APP/common/constants/env-keys.const"; | ||
import { RefreshTokenEntity } from "@APP/entities/refresh-token.entity"; | ||
|
||
export default setSeederFactory(RefreshTokenEntity, async (faker) => { | ||
const payload = { | ||
email: faker.internet.email(), | ||
sub: faker.number.int(), | ||
type: "refresh", | ||
}; | ||
|
||
const secret = process.env[ENV_JWT_SECRET_KEY] || "secret"; | ||
const expiresIn = "3600"; | ||
|
||
export default setSeederFactory(RefreshTokenEntity, async () => { | ||
const refreshToken = new RefreshTokenEntity(); | ||
|
||
const token = jwt.sign(payload, secret, { expiresIn }); | ||
refreshToken.token = await bcrypt.hash(token, 10); | ||
// bcrypt 해시가 너무 오래 걸려 미리 해싱 | ||
refreshToken.token = | ||
"$2b$10$ndYzoPCCXt.24qzOusAB/OYMqaS1UKVqQsGvQh9t/MaqFqgg.g0fO"; | ||
|
||
return refreshToken; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.