feat: add auth and related utilities #3
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes several updates and new features across various parts of the project. The most important changes include updates to dependencies and scripts, new middleware for authentication, and database schema modifications.
Dependency and Script Updates:
package.json
: Added new scripts (db:generate
,db:migrate
,deps:update
) and updated several dependencies to their latest versions.Authentication and Middleware:
src/common/middlewares/auth.middleware.ts
: Added new middleware functions for authentication, including session validation and role-based access control.src/app.ts
: Updated application routing to includeauthRouter
and changed the base route for API endpoints.Database Schema Changes:
src/db/migrations/0000_open_black_crow.sql
: Created new tables and types for user accounts and sessions, with appropriate foreign key constraints.src/db/migrations/0001_nasty_cobalt_man.sql
: Modified the data type of theid
column in thesession
table.src/db/migrations/0002_equal_grandmaster.sql
: Updated theid
column type in theaccount
table and added a unique constraint.Utility Functions:
src/common/utils/crypto.lib.ts
: Added functions for password hashing, verification, and strength validation using@node-rs/argon2
and@oslojs/crypto
.src/common/utils/sessions.util.ts
: Added functions for generating, validating, and invalidating session tokens.This pull request includes several updates and improvements across the codebase, including dependency updates, new utility functions, and database schema changes. The most important changes are listed below:Dependency and Configuration Updates:
package.json
and added new scripts for database operations..vscode/settings.json
.Code Enhancements:
AuthRoles
to use a more dynamic approach by leveraging arrays and types insrc/common/enums/index.ts
.src/common/utils/crypto.lib.ts
andsrc/common/utils/sessions.util.ts
. [1] [2]Database Schema Changes:
account
,session
, andusers
tables insrc/db/migrations/
. [1] [2]src/db/migrations/meta/
. [1] [2] [3]Miscellaneous:
src/app.ts
and other files. [1] [2]jsonContentRequired
insrc/common/helpers/json-content-required.ts
.notFoundSchema
insrc/common/lib/constants.lib.ts
.src/common/middlewares/pino-logger.middleware.ts
.