Skip to content

Commit

Permalink
Merge pull request #57 from dreampipcom/dev
Browse files Browse the repository at this point in the history
r006
  • Loading branch information
angeloreale authored Aug 30, 2024
2 parents 6cb9391 + bfcf11f commit 0d3db2d
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

patreon: angeloreale
7 changes: 7 additions & 0 deletions .github/workflows/deploy_gcp_prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ jobs:
NEXUS_STANDALONE=true
PRISMA_PRIVATE_URI=${{ secrets.MONGODB_PRIVATE_URI_PROD }}
PRISMA_PUBLIC_URI=${{ secrets.MONGODB_PUBLIC_URI_PROD }}
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN_PROD }}
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN_PROD }}
NEXT_PUBLIC_SENTRY_DSN=${{ secrets.NEXT_PUBLIC_SENTRY_DSN_PROD }}
SENTRY_PROJECT=${{ secrets.SENTRY_PROJECT_PROD }}
SENTRY_ORG=${{ secrets.SENTRY_ORG_PROD }}
VERCEL_GIT_COMMIT_SHA=${{ github.sha }}
- name: hypnos::deploy_prod::docker::Generate artifact attestation
uses: actions/attest-build-provenance@v1
Expand Down
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ ARG MONGODB_PUBLIC_URI
ARG NEXUS_MODE
ARG NEXUS_KEEPALIVE

ARG SENTRY_AUTH_TOKEN
ARG SENTRY_PROJECT
ARG SENTRY_ORG
ARG NEXT_PUBLIC_SENTRY_DSN
ARG VERCEL_GIT_COMMIT_SHA

# ENV FROM ARGS VARS
ENV AUTH_GITHUB_ID=$AUTH_GITHUB_ID
ENV AUTH_GITHUB_SECRET=$AUTH_GITHUB_SECRET
Expand Down Expand Up @@ -120,6 +126,12 @@ ENV MONGODB_PUBLIC_URI=$MONGODB_PUBLIC_URI
ENV NEXUS_MODE=$NEXUS_MODE
ENV NEXUS_KEEPALIVE=$NEXUS_KEEPALIVE

ENV SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
ENV SENTRY_PROJECT=$SENTRY_PROJECT
ENV SENTRY_ORG=$SENTRY_ORG
ENV NEXT_PUBLIC_SENTRY_DSN=$NEXT_PUBLIC_SENTRY_DSN
ENV VERCEL_GIT_COMMIT_SHA=$VERCEL_GIT_COMMIT_SHA


RUN \
if [ -f yarn.lock ]; then yarn run build:vm; \
Expand Down Expand Up @@ -176,6 +188,12 @@ ARG MONGODB_PUBLIC_URI
ARG NEXUS_MODE
ARG NEXUS_KEEPALIVE

ARG SENTRY_AUTH_TOKEN
ARG SENTRY_PROJECT
ARG SENTRY_ORG
ARG NEXT_PUBLIC_SENTRY_DSN
ARG VERCEL_GIT_COMMIT_SHA

# ENV FROM ARGS VARS
ENV AUTH_GITHUB_ID=$AUTH_GITHUB_ID
ENV AUTH_GITHUB_SECRET=$AUTH_GITHUB_SECRET
Expand Down Expand Up @@ -216,6 +234,12 @@ ENV MONGODB_PUBLIC_URI=$MONGODB_PUBLIC_URI
ENV NEXUS_MODE=$NEXUS_MODE
ENV NEXUS_KEEPALIVE=$NEXUS_KEEPALIVE

ENV SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
ENV SENTRY_PROJECT=$SENTRY_PROJECT
ENV SENTRY_ORG=$SENTRY_ORG
ENV NEXT_PUBLIC_SENTRY_DSN=$NEXT_PUBLIC_SENTRY_DSN
ENV VERCEL_GIT_COMMIT_SHA=$VERCEL_GIT_COMMIT_SHA

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

Expand Down
17 changes: 14 additions & 3 deletions lib/auth/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// constants.ts TS-Doc?
/* eslint @typescript-eslint/consistent-type-assertions:0 */
import _ from 'lodash';
import type { NextAuthConfig } from 'next-auth';
import { v4 as uuid } from 'uuid';
import type { PrismaClient } from '@prisma/client';
Expand Down Expand Up @@ -40,17 +41,21 @@ export const GetSession = async ({ cookies = '' }) => {

// schema sanitizer
const allUsersSideEffects = async ({ user }: any) => {
if (!user) return;
const services = await GetPrivateCommonServices({});
const abilities = await GetPrivateCommonAbilities({});
const commonServices = services.map((service: any) => service?.id).map((el: any) => el);
const commonAbilities = abilities.map((ability: any) => ability?.id).map((el: any) => el);

const [dpcpAbility] = await GetPrivateAbilities({ type: 'R', target: 'dpcp-vibemodulator', action: 'view-listings' });

await UpdatePrivateUserServices({ user, services: [...commonServices, ...user.servicesIds], upsert: false });
const nextAbilities = _.uniq([...commonAbilities, ...user.abilitiesIds, dpcpAbility?.id]);
const nextServices = _.uniq([...commonServices, ...user.servicesIds]);

await UpdatePrivateUserServices({ user, services: nextServices, upsert: false });
await UpdatePrivateUserAbilities({
user,
abilities: [...commonAbilities, ...user.abilitiesIds, dpcpAbility.id],
abilities: nextAbilities,
upsert: false,
});
};
Expand Down Expand Up @@ -114,6 +119,8 @@ export const authConfig = {
const { user, isNewUser } = props;
try {
if (isNewUser) {
// [DPCP-125] https://www.notion.so/angeloreale/Hypnos-Feature-use-lib-log-for-server-console-logs-67993255fc4e4010a08fee263089f9b7?pvs=4
console.log('dp::hypnos::Running sign-up side-effects');
await allUsersSideEffects({ user });
}
} catch (e) {
Expand All @@ -127,7 +134,11 @@ export const authConfig = {
async signIn(props) {
const { user } = props;
try {
await allUsersSideEffects({ user });
if (user) {
// [DPCP-125] https://www.notion.so/angeloreale/Hypnos-Feature-use-lib-log-for-server-console-logs-67993255fc4e4010a08fee263089f9b7?pvs=4
console.log('dp::hypnos::Callback: Running sign-in side-effects');
await allUsersSideEffects({ user });
}
} catch (e) {
console.warn(`Code 004: Log-in side-effects failed. If it's a new user, plese ignore: ${e}`);
}
Expand Down
20 changes: 14 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@prisma/extension-accelerate": "1.1.0",
"@prisma/nextjs-monorepo-workaround-plugin": "5.18.0",
"@types/json-schema": "7.0.15",
"@types/lodash": "^4.17.7",
"@types/node": "20",
"@types/react": "18.3.2",
"@types/uuid": "9.0.8",
Expand All @@ -73,7 +74,7 @@
"eslint-config-alloy": "5.1.2",
"eslint-config-next": "14.0.4",
"husky": "9.0.11",
"lodash": "4.17.21",
"lodash": "^4.17.21",
"mongodb": "5.0.0",
"next-auth": "5.0.0-beta.20",
"nodemailer": "6.9.14",
Expand Down
1 change: 1 addition & 0 deletions src/app/api/v1/public/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const generateErrorResponse = (e: any, status: number) => {
};

// export const dynamic = 'force-static';

export async function GET(request: CombineRequest) {
try {
const url = new URL(request.url);
Expand Down
1 change: 1 addition & 0 deletions src/app/api/v1/services/dpcp-vibemodulator/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const generateErrorResponse = (e: any, status: number) => {
};

// export const dynamic = 'force-static';

export async function GET(request: CombineRequest) {
try {
const cookies = request?.cookies?.toString() || request?.headers?.get('cookies');
Expand Down
1 change: 1 addition & 0 deletions src/app/api/v1/services/rickmorty/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const generateErrorResponse = (e: any, status: number) => {
};

// export const dynamic = 'force-static';

export async function GET(request: CombineRequest) {
try {
const url = new URL(request.url);
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/v1/user/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const generateErrorResponse = (e: any, status: number) => {
};
};

// export const dynamic = 'force-static';
export const dynamic = 'force-dynamic';

export async function POST(request: CombineRequest) {
const response = { error: generateErrorResponse({ message: 'Code 000/0: Non-identified error.' }, 500) };
Expand Down

0 comments on commit 0d3db2d

Please sign in to comment.