-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:BinaryStudioAcademy/bsa-2024-bebalance
- Loading branch information
Showing
112 changed files
with
1,749 additions
and
290 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
".": "1.3.0", | ||
"apps/backend": "0.0.0", | ||
"apps/frontend": "0.0.0", | ||
"packages/shared": "0.0.0" | ||
".": "1.9.0", | ||
"apps/backend": "1.3.0", | ||
"apps/frontend": "1.4.0", | ||
"packages/shared": "1.4.0" | ||
} |
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,33 @@ | ||
# Changelog | ||
|
||
## [1.3.0](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/compare/backend-v1.2.0...backend-v1.3.0) (2024-08-21) | ||
|
||
|
||
### Features | ||
|
||
* impl protected routing bb-11 ([#50](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/issues/50)) ([5f2c71c](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/commit/5f2c71ccfd1dd50f4a894d1ab391690b674ab2eb)) | ||
|
||
## [1.2.0](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/compare/backend-v1.1.0...backend-v1.2.0) (2024-08-21) | ||
|
||
|
||
### Features | ||
|
||
* authorization token (JWT) bb-10 ([#40](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/issues/40)) ([16e3c35](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/commit/16e3c353ff700ab27a7b6af4fa7b3c17059cc916)) | ||
* **backend:** add categories migration bb-34 ([#100](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/issues/100)) ([43ececb](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/commit/43ececb50a49723b2d0ff52ef1041dcfe49be225)) | ||
|
||
## [1.1.0](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/compare/backend-v1.0.0...backend-v1.1.0) (2024-08-21) | ||
|
||
|
||
### Features | ||
|
||
* implement sign-in functionality bb-6 ([#37](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/issues/37)) ([1f2b54c](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/commit/1f2b54c94efa5e1553bc8b4bd24f2fdf2b0f8053)) | ||
|
||
## 1.0.0 (2024-08-20) | ||
|
||
|
||
### Features | ||
|
||
* add continuous delivery bb-3 ([#62](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/issues/62)) ([4106756](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/commit/4106756bc7ecd9119ecf302b5d0df67089aa5961)) | ||
* add mobile starter bb-2 ([#27](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/issues/27)) ([a9381f3](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/commit/a9381f3827dcce9b01c91deaa8343bc9fe212ffc)) | ||
* add web starter bb-1 ([#4](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/issues/4)) ([46357b5](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/commit/46357b59ff3818e0e5bbdcb02b10a3689c9bb1d0)) | ||
* sign up bb-8 ([#46](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/issues/46)) ([833b096](https://github.com/BinaryStudioAcademy/bsa-2024-bebalance/commit/833b096800fda00136885ae1bffedada943a1e8a)) |
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
31 changes: 31 additions & 0 deletions
31
apps/backend/src/db/migrations/20240821111749_create_categories_table.ts
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,31 @@ | ||
import { type Knex } from "knex"; | ||
|
||
const TABLE_NAME = "categories"; | ||
|
||
const ColumnName = { | ||
CREATED_AT: "created_at", | ||
ID: "id", | ||
NAME: "name", | ||
UPDATED_AT: "updated_at", | ||
} as const; | ||
|
||
async function up(knex: Knex): Promise<void> { | ||
await knex.schema.createTable(TABLE_NAME, (table) => { | ||
table.increments(ColumnName.ID).primary(); | ||
table.string(ColumnName.NAME).notNullable().unique(); | ||
table | ||
.dateTime(ColumnName.CREATED_AT) | ||
.notNullable() | ||
.defaultTo(knex.fn.now()); | ||
table | ||
.dateTime(ColumnName.UPDATED_AT) | ||
.notNullable() | ||
.defaultTo(knex.fn.now()); | ||
}); | ||
} | ||
|
||
async function down(knex: Knex): Promise<void> { | ||
await knex.schema.dropTableIfExists(TABLE_NAME); | ||
} | ||
|
||
export { down, up }; |
32 changes: 32 additions & 0 deletions
32
apps/backend/src/db/migrations/20240821131722_add_categories_data.ts
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,32 @@ | ||
import { type Knex } from "knex"; | ||
|
||
const TABLE_NAME = "categories"; | ||
|
||
const ColumnName = { | ||
NAME: "name", | ||
} as const; | ||
|
||
const CATEGORIES = [ | ||
"Physical", | ||
"Work", | ||
"Friends", | ||
"Love", | ||
"Money", | ||
"Free time", | ||
"Spiritual", | ||
"Mental", | ||
]; | ||
|
||
async function up(knex: Knex): Promise<void> { | ||
await knex(TABLE_NAME).insert( | ||
CATEGORIES.map((name) => ({ | ||
[ColumnName.NAME]: name, | ||
})), | ||
); | ||
} | ||
|
||
async function down(knex: Knex): Promise<void> { | ||
await knex(TABLE_NAME).whereIn(ColumnName.NAME, CATEGORIES).del(); | ||
} | ||
|
||
export { down, up }; |
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,2 +1,2 @@ | ||
export { RelationName } from "./relation-name.enum.js"; | ||
export { APIPath, AppEnvironment, ServerErrorType } from "shared"; | ||
export { APIPath, AppEnvironment, ErrorMessage, ServerErrorType } from "shared"; |
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
1 change: 1 addition & 0 deletions
1
apps/backend/src/libs/modules/database/libs/enums/database-table-name.enum.ts
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
8 changes: 7 additions & 1 deletion
8
apps/backend/src/libs/modules/encrypt/libs/types/encrypt.type.ts
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,5 +1,11 @@ | ||
type Encrypt = { | ||
encrypt: (data: string) => Promise<{ hash: string; salt: string }>; | ||
compare: ( | ||
password: string, | ||
passwordHash: string, | ||
salt: string, | ||
) => Promise<boolean>; | ||
|
||
encrypt: (password: string) => Promise<{ hash: string; salt: string }>; | ||
}; | ||
|
||
export { type Encrypt }; |
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,3 +1,3 @@ | ||
export { HTTPCode } from "./libs/enums/enums.js"; | ||
export { HTTPCode, HTTPHeader } from "./libs/enums/enums.js"; | ||
export { HTTPError } from "./libs/exceptions/exceptions.js"; | ||
export { type HTTPMethod } from "./libs/types/types.js"; |
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 +1 @@ | ||
export { HTTPCode } from "shared"; | ||
export { HTTPCode, HTTPHeader } from "shared"; |
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
11 changes: 11 additions & 0 deletions
11
apps/backend/src/libs/modules/server-application/libs/constants/constants.ts
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 @@ | ||
import { AuthApiPath } from "~/modules/auth/auth.js"; | ||
|
||
import { APIPath } from "../enums/enums.js"; | ||
|
||
const WHITE_ROUTES: string[] = [ | ||
APIPath.AUTH, | ||
`${APIPath.AUTH}${AuthApiPath.SIGN_IN}`, | ||
`${APIPath.AUTH}${AuthApiPath.SIGN_UP}`, | ||
]; | ||
|
||
export { WHITE_ROUTES }; |
1 change: 1 addition & 0 deletions
1
apps/backend/src/libs/modules/server-application/libs/enums/enums.ts
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 @@ | ||
export { APIPath } from "~/libs/enums/enums.js"; |
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,33 @@ | ||
import { JWTPayload, jwtVerify, JWTVerifyResult, SignJWT } from "jose"; | ||
|
||
type Constructor = { | ||
algorithm: string; | ||
expirationTime: string; | ||
secret: Uint8Array; | ||
}; | ||
|
||
class BaseToken<T extends JWTPayload> { | ||
private algorithm: string; | ||
private expirationTime: string; | ||
private secret: Uint8Array; | ||
|
||
constructor({ algorithm, expirationTime, secret }: Constructor) { | ||
this.secret = secret; | ||
this.algorithm = algorithm; | ||
this.expirationTime = expirationTime; | ||
} | ||
|
||
public async createToken(payload: T): Promise<string> { | ||
return await new SignJWT(payload) | ||
.setProtectedHeader({ alg: this.algorithm }) | ||
.setIssuedAt() | ||
.setExpirationTime(this.expirationTime) | ||
.sign(this.secret); | ||
} | ||
|
||
public async decode(token: string): Promise<JWTVerifyResult<T>> { | ||
return await jwtVerify<T>(token, this.secret); | ||
} | ||
} | ||
|
||
export { BaseToken }; |
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,13 @@ | ||
import { config } from "~/libs/modules/config/config.js"; | ||
import { TokenPayload } from "~/libs/types/types.js"; | ||
|
||
import { BaseToken } from "./base-token.module.js"; | ||
|
||
const token = new BaseToken<TokenPayload>({ | ||
algorithm: config.ENV.JWT.ALGORITHM, | ||
expirationTime: config.ENV.JWT.EXPIRATION_TIME, | ||
secret: Buffer.from(config.ENV.JWT.SECRET), | ||
}); | ||
|
||
export { BaseToken } from "./base-token.module.js"; | ||
export { token }; |
Oops, something went wrong.