Skip to content

feat(modules/auth): semi-intergation of auth module#12

Closed
itssimmons wants to merge 11 commits intomainfrom
feat/auth
Closed

feat(modules/auth): semi-intergation of auth module#12
itssimmons wants to merge 11 commits intomainfrom
feat/auth

Conversation

@itssimmons
Copy link
Copy Markdown
Contributor

Pull Request Template

📌 Description

Provide a clear and concise description of what this PR does.

  • What problem does it solve?
  • Why is this change necessary?

🔧 Type of Change

Select all that apply:

  • Feature (new functionality)
  • Fix (bug fix)
  • Refactor (code improvement, no behavior change)
  • Docs (documentation only)
  • Test (adding or updating tests)
  • Chore (build, tooling, dependencies, etc.)

🧪 How Has This Been Tested?

Describe the testing strategy:

  • Unit tests
  • Integration tests
  • Manual testing

Steps to reproduce/test:
1.
2.
3.


📂 Related Issues

Link any related issues:

  • Closes #
  • Related to #

⚠️ Breaking Changes

  • Yes
  • No

If yes, describe the impact and migration steps:


📸 Screenshots / Logs (if applicable)

Add screenshots, request/response examples, or logs if helpful.


✅ Checklist

Ensure your PR meets the following:

  • Code follows project conventions
  • Self-review completed
  • Tests added/updated where necessary
  • Documentation updated (if needed)
  • No sensitive data exposed (API keys, secrets)

💬 Additional Notes

Anything else reviewers should know.

Copilot AI review requested due to automatic review settings May 2, 2026 15:29
Comment thread modules/users/controllers/index.controller.ts Fixed
Comment thread plugins/zod.ts Fixed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

🚀 Preview deployed: https://api-preview-12-nnratsflva-uc.a.run.app

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR starts integrating authentication into the Fastify app by adding JWT request guarding, signup/login/refresh/revoke endpoints, early Google OAuth handlers, shared auth-related types, and supporting Prisma/i18n/container configuration updates. It fits into the codebase as the first pass at wiring the modules/auth module into the versioned API and runtime bootstrap.

Changes:

  • Added JWT/session handling, signup/login/refresh/revoke controller logic, and auth route registration under /1/auth.
  • Introduced early Google OAuth flow pieces, new auth schemas/models/types, and shared exception classes.
  • Updated Prisma schema, i18n namespaces/locales, Docker compose/dev container setup, and package dependencies to support auth work.

Reviewed changes

Copilot reviewed 36 out of 42 changed files in this pull request and generated 24 comments.

Show a summary per file
File Description
plugins/zod.ts Added a placeholder Fastify plugin intended for request validation/localization work.
plugins/jwt.ts Added a global JWT pre-handler that populates req.user from Redis-backed sessions.
plugins/i18n.ts Exposed language alongside t() on Fastify requests.
package.json Added auth/OAuth dependencies and bcrypt typings.
modules/users/models/User.d.ts Added a lightweight shared user interface for session/auth typing.
modules/users/controllers/index.controller.ts Added a commented-out placeholder controller scaffold for user features.
modules/auth/types/jwt.d.ts Reshaped JWT subject/payload typings for access/refresh tokens.
modules/auth/serivces/jwt.service.ts Added token creation helper for access/refresh JWT issuance.
modules/auth/serivces/google.service.ts Added an empty Google OAuth service namespace placeholder.
modules/auth/schemas/signup.schema.ts Added signup body validation with nickname rules.
modules/auth/schemas/signin.schema.ts Added a sign-in schema definition.
modules/auth/schemas/refresh-token.schema.ts Switched refresh-token schema to a named export.
modules/auth/schemas/index.schema.ts Added barrel exports for auth schemas.
modules/auth/schemas/google-user.schema.ts Added schema for Google user profile payloads.
modules/auth/schemas/credential.schema.ts Reworked login credential validation to accept email or nickname.
modules/auth/routes/index.router.ts Expanded auth routes to include signup, Google OAuth, and HTTP verb changes.
modules/auth/models/Session.d.ts Added session shape stored in Redis.
modules/auth/models/Auth.d.ts No visible diff was provided; appears to be an empty/placeholder file.
modules/auth/exceptions/unauthorized.exception.ts Removed module-local unauthorized exception in favor of shared exceptions.
modules/auth/exceptions/notfound.exception.ts Removed module-local not-found exception in favor of shared exceptions.
modules/auth/controllers/index.controller.ts Replaced stub auth flows with Prisma/bcrypt/Redis-backed signup, login, logout, refresh, and revoke handlers.
modules/auth/controllers/google-oauth.controller.ts Added Google OAuth URL generation and callback handling with user/session creation.
locales/pt-BR/zod.json Added Zod namespace file for Portuguese translations.
locales/fr-FR/zod.json Added Zod namespace file for French translations.
locales/es-ES/zod.json Added Spanish translation for nickname validation rules.
locales/es-ES/errors.json Added a new Spanish auth-related error string.
locales/en-US/zod.json Added English translation for nickname validation rules.
index.ts Registered JWT plugin globally and added verbose request logging on /echo.
exceptions/unauthorized.exception.ts Added shared unauthorized exception class with status code.
exceptions/notfound.exception.ts Added shared not-found exception class with status code.
exceptions/index.exception.ts Added barrel export for shared exceptions.
exceptions/conflict.exception.ts Added shared conflict exception class with status code.
database/redis/client.ts Renamed Redis config variables and client export for clarity.
database/prisma/schema.prisma Extended auth-related schema with nullable OAuth links, metadata, relations, and new providers.
database/prisma/migrations/20260502151239/migration.sql Added migration to make OAuth account user links nullable and add FK behavior.
database/prisma/migrations/20260502141005/migration.sql Added migration for new OAuth enum values and provider metadata/avatar nullability.
config/i18n.ts Added zod namespace and typed the i18n config shape.
compose.yml Added a dev compose stack for API, Postgres, and Redis.
ci/Dockerfile.dev Added a development Dockerfile for Bun/Prisma.
bun.lock Updated lockfile for new dependencies.
@types/i18next.d.ts Added a minimal ambient i18next.TFunction type.
.env.example Reworked env template toward explicit Postgres/Redis variables.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread modules/auth/controllers/google-oauth.controller.ts Outdated
Comment thread modules/auth/controllers/google-oauth.controller.ts
Comment thread modules/auth/controllers/index.controller.ts Outdated
Comment thread modules/auth/controllers/google-oauth.controller.ts Outdated
Comment thread compose.yml
Comment thread modules/auth/controllers/google-oauth.controller.ts Outdated
Comment thread modules/auth/controllers/index.controller.ts Outdated
Comment thread compose.yml
Comment thread modules/auth/controllers/index.controller.ts
Comment thread modules/auth/controllers/index.controller.ts Outdated
… refresh token

Agent-Logs-Url: https://github.com/dojoh-dev/api/sessions/e51ba94d-b8f5-4c51-8fb6-1f6c2da7b64f

Co-authored-by: itssimmons <62354548+itssimmons@users.noreply.github.com>
…on native login

Agent-Logs-Url: https://github.com/dojoh-dev/api/sessions/f56905a4-f168-4cf2-9242-dd5ea3a6ad28

Co-authored-by: itssimmons <62354548+itssimmons@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 2, 2026 16:08
@itssimmons itssimmons review requested due to automatic review settings May 2, 2026 16:08
Copilot AI review requested due to automatic review settings May 2, 2026 19:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 48 changed files in this pull request and generated 25 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread modules/auth/controllers/discord-oauth.controller.ts Outdated
Comment thread config/jwt.ts Outdated
Comment thread modules/auth/controllers/index.controller.ts
Comment thread modules/auth/controllers/index.controller.ts Outdated
Comment thread modules/auth/controllers/index.controller.ts
Comment thread .env.example Outdated
Comment thread index.ts Outdated
Comment thread modules/auth/controllers/discord-oauth.controller.ts Outdated
Comment thread index.ts Outdated
Comment thread modules/auth/controllers/discord-oauth.controller.ts Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

🚀 Preview deployed: https://api-preview-12-nnratsflva-uc.a.run.app

Copilot AI review requested due to automatic review settings May 3, 2026 01:21
@itssimmons itssimmons review requested due to automatic review settings May 3, 2026 01:21
Copilot AI review requested due to automatic review settings May 3, 2026 01:29
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

🚀 Preview deployed: https://api-preview-12-nnratsflva-uc.a.run.app

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 48 changed files in this pull request and generated 14 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread modules/auth/controllers/discord-oauth.controller.ts Outdated
Comment on lines +48 to +56
const { tokens } = await oauth2Client.getToken(code);
oauth2Client.setCredentials(tokens);

const oauth2 = google.oauth2({
auth: oauth2Client,
version: "v2",
});

const { data } = await oauth2.userinfo.get();
Comment thread modules/auth/controllers/github-oauth.controller.ts Outdated
Comment thread modules/auth/routes/oauth.router.ts
Comment on lines +125 to +133
const user = await prisma.user.upsert({
where: {
email: discordUser.email,
},
update: {
// Do nothing, we don't want to overwrite existing user data
},
create: {
email: discordUser.email || "",
Comment on lines +136 to +138
create: {
email: githubUser.email ?? "",
nickname: githubUser.login,
Comment on lines +99 to +101
create: {
email: googleUser.email,
nickname: googleUsername,
Comment thread .env.example

GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_REDIRECT_URI=https://example.com/auth/google/callback
Comment thread .env.example

DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
DISCORD_REDIRECT_URI=https://example.com/auth/github/callback
Comment on lines +183 to +187
reply.setCookie("oauth_state", state, {
httpOnly: true,
secure: true,
sameSite: "lax",
maxAge: 60 * 5, // 5m
return reply.status(400).send("Discord user ID not found");
}

const discordEmail =
return reply.redirect(authorizationUrl);
},
oneTap: async (req: FastifyRequest, reply: FastifyReply) => {
const { credential } = req.body as {
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

🚀 Preview deployed: https://api-preview-12-nnratsflva-uc.a.run.app

@itssimmons
Copy link
Copy Markdown
Contributor Author

Closing because it got way too messy

@itssimmons itssimmons closed this May 7, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

🧹 Preview no longer available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants