Skip to content

Commit

Permalink
[DPCP-13] [DPCP-14] ar(feat) 2024 2nd semester rebase. (#3)
Browse files Browse the repository at this point in the history
* ar(feat) 2024 2nd semester rebase.

* ar(feat) 2024 2nd semester rebase.

* ar(feat) 2024 2nd semester rebase.

* ar(feat) 2024 2nd semester rebase.

* ar(feat) 2024 2nd semester rebase.

* ar(feat) 2024 2nd semester rebase.

* ar(feat) DPCP-13: Valid Schema

* ar(feat) DPCP-13: Get seed to work

* ar(feat) DPCP-13: Get seed to work

* ar(feat) DPCP-13: Get seed to work

* ar(feat) DPCP-13: Get seed to work

* ar(feat) fix lock

* ar(feat) lint

* ar(feat) re-add socket

* ar(feat) sort it

* ar(feat) sort it
  • Loading branch information
angeloreale committed Jul 13, 2024
1 parent a4f05e0 commit 8078349
Show file tree
Hide file tree
Showing 27 changed files with 3,519 additions and 1,017 deletions.
48 changes: 48 additions & 0 deletions .env.local.public
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# .env.local.public
# please copy and fill this to .env.local
# or add it to you ci environment


# ----------------
# PRIVATE VARIABLES
# @@@ WARNING: DON'T ADD NEXT_PUBLIC_* VARIABLES IF THEY'RE PRIVATE @@@

# env specific
NEXTAUTH_SECRET=random-string
NEXTAUTH_URL=http://localhost:3001
MAIN_URL=http://localhost:3000

# context specific
GITHUB_ID=
GITHUB_SECRET=
INSTAGRAM_CLIENT_ID=
INSTAGRAM_CLIENT_SECRET=
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
APPLE_CLIENT_ID=
APPLE_CLIENT_SECRET=

# env agnostic/specific: depends on your setup
EMAIL_SERVER=
EMAIL_FROM=

# modes: "full" (feats: enable-multi-tenancy,;)
NEXUS_MODE=

# base path: server-only
NEXUS_BASE_PATH=

# env agnostic
MONGODB_URI=

# default db
MONGODB_DATABASE=

# optional dbs (if used, all must be filled)
MONGODB_USERS_DATABASE=
MONGODB_ORGS_DATABASE=
MONGODB_DEFAULT_ORG=

# config
ENABLE_LOG=true
LOG_DEPTH=1
50 changes: 4 additions & 46 deletions .env.public
Original file line number Diff line number Diff line change
@@ -1,48 +1,6 @@
# .env.local.public
# please copy and fill this to .env.local
# .env.public
# please copy and fill this to .env
# or add it to you ci environment


# ----------------
# PRIVATE VARIABLES
# @@@ WARNING: DON'T ADD NEXT_PUBLIC_* VARIABLES IF THEY'RE PRIVATE @@@

# env specific
NEXTAUTH_SECRET=random-string
NEXTAUTH_URL=http://localhost:3001
MAIN_URL=http://localhost:3000

# context specific
GITHUB_ID=
GITHUB_SECRET=
INSTAGRAM_CLIENT_ID=
INSTAGRAM_CLIENT_SECRET=
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
APPLE_CLIENT_ID=
APPLE_CLIENT_SECRET=

# env agnostic/specific: depends on your setup
EMAIL_SERVER=
EMAIL_FROM=

# modes: "full" (feats: enable-multi-tenancy,;)
NEXUS_MODE=

# base path: server-only
NEXUS_BASE_PATH=

# env agnostic
MONGODB_URI=

# default db
MONGODB_DATABASE=

# optional dbs (if used, all must be filled)
MONGODB_USERS_DATABASE=
MONGODB_ORGS_DATABASE=
MONGODB_DEFAULT_ORG=

# config
ENABLE_LOG=true
LOG_DEPTH=1
MONGODB_PRIVATE_URI=""
MONGODB_PUBLIC_URI=""
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ yarn-debug.log*
yarn-error.log*

# local env files
.env
.env*.local

# vercel
Expand All @@ -38,7 +39,6 @@ next-env.d.ts
# modules
.gitmodules
/modules/*
mock/

# private
*.private
4 changes: 4 additions & 0 deletions lib/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ export {

/* rm-decorators */
export { decorateRMCharacters } from './decorators';

/* prisma */
export { default as PrivatePrisma } from './prisma-private-connector';
export { default as PublicPrisma } from './prisma-public-connector';
60 changes: 60 additions & 0 deletions lib/model/interfaces/get-public-listings-iface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// @controller/get-public-listings-iface.ts
import { PublicPrisma } from '@model';

const PAGE_SIZE = 100;

const getPublicListings = async ({ page = 0, offset = 0, limit = PAGE_SIZE, filters = [] }: any) => {
const adaptQuery: any = {
skip: page * (limit + offset),
take: limit,
};

if (filters?.length) {
try {
const supportedTaxonomies: Record<string, any> = {
modalidade1: {
name: {
es: 'modalidade1',
},
nature: 'modalidades',
query: {
OR: [
{ taxonomies: { some: { name: { is: { es: 'Modalidad 1' } } } } },
{ listingTaxonomies: { some: { name: { is: { es: 'Modalidad 1' } } } } },
],
},
},
especie1: {
name: {
es: 'especie1',
},
nature: 'especies',
query: {
OR: [
{ taxonomies: { some: { name: { is: { es: 'Taxonomy Term 1' } } } } },
{ listingTaxonomies: { some: { name: { is: { es: 'Taxonomy Term 1' } } } } },
],
},
},
};

const query: any = filters?.reduce((acc: any, filter: string) => {
if (!acc.OR) acc.OR = [];
acc.OR.push(supportedTaxonomies[filter].query);
return acc;
}, {});

adaptQuery.where = {
...query,
};
} catch (e) {
throw new Error('Code 001: Wrong filter');
}
}

const response = await PublicPrisma.publicListings.findMany(adaptQuery);

return response;
};

export default getPublicListings;
3 changes: 3 additions & 0 deletions lib/model/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export { getUserMeta } from './mdb-get-interface';
// write
export { commitUpdate, initSignUpUser } from './mdb-update-interface';

/* prisma-public-ifaces */
export { default as GetPublicListings } from './get-public-listings-iface';

/* rm */

// read
Expand Down
15 changes: 15 additions & 0 deletions lib/model/prisma-private-connector.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { PrismaClient as PrivatePrisma } from '@dreampipcom/db-private/prisma-client';

const prismaClientSingleton = () => {
return new PrivatePrisma();
};

declare const globalThis: {
prismaPrivateGlobal: ReturnType<typeof prismaClientSingleton>;
} & typeof global;

const privatePrisma = globalThis.prismaPrivateGlobal ?? prismaClientSingleton();

export default privatePrisma;

if (process.env.NODE_ENV !== 'production') globalThis.prismaPrivateGlobal = privatePrisma;
15 changes: 15 additions & 0 deletions lib/model/prisma-public-connector.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { PrismaClient as PublicPrisma } from '@dreampipcom/db-public/prisma-client';

const prismaClientSingleton = () => {
return new PublicPrisma();
};

declare const globalThis: {
prismaPublicGlobal: ReturnType<typeof prismaClientSingleton>;
} & typeof global;

const publicPrisma = globalThis.prismaPublicGlobal ?? prismaClientSingleton();

export default publicPrisma;

if (process.env.NODE_ENV !== 'production') globalThis.prismaPublicGlobal = publicPrisma;
Loading

0 comments on commit 8078349

Please sign in to comment.