mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-09 23:48:36 +01:00
Restrucure consumer + monorepo
This commit is contained in:
@@ -2,15 +2,18 @@ module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'consumer',
|
||||
exec_mode: 'fork',
|
||||
exec_mode: 'cluster',
|
||||
instances: '2',
|
||||
script: './dist/consumer/src/index.js',
|
||||
env: {
|
||||
MONGO_CONNECTION_STRING: "",
|
||||
EMAIL_SERVICE: '',
|
||||
BREVO_API_KEY: '',
|
||||
MONGO_CONNECTION_STRING: '',
|
||||
REDIS_URL: "",
|
||||
REDIS_USERNAME: "",
|
||||
REDIS_PASSWORD: "",
|
||||
STREAM_NAME: "",
|
||||
GROUP_NAME: ""
|
||||
GROUP_NAME: ''
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@getbrevo/brevo": "^2.2.0",
|
||||
"mongoose": "^8.3.2",
|
||||
"redis": "^4.6.14",
|
||||
"ua-parser-js": "^1.0.37"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -11,15 +8,15 @@
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.4.5"
|
||||
},
|
||||
"name": "consumer-database",
|
||||
"name": "consumer",
|
||||
"version": "1.0.0",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"dev": "node scripts/start_dev.js",
|
||||
"compile": "tsc",
|
||||
"build": "node ../scripts/build.js",
|
||||
"build_project": "node ../scripts/build.js",
|
||||
"build": "npm run compile && npm run build_project && npm run create_db",
|
||||
"create_db": "cd scripts && ts-node create_database.ts",
|
||||
"build_all": "npm run compile && npm run build && npm run create_db",
|
||||
"docker-build": "docker build -t litlyx-consumer -f Dockerfile ../",
|
||||
"docker-inspect": "docker run -it litlyx-consumer sh"
|
||||
},
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { ProjectModel } from "@schema/ProjectSchema";
|
||||
import { ProjectModel } from "@schema/project/ProjectSchema";
|
||||
import { UserModel } from "@schema/UserSchema";
|
||||
import { LimitNotifyModel } from "@schema/broker/LimitNotifySchema";
|
||||
import EmailService from '@services/EmailService';
|
||||
import { requireEnv } from "@utils/requireEnv";
|
||||
import { TProjectLimit } from "@schema/ProjectsLimits";
|
||||
import { TProjectLimit } from "@schema/project/ProjectsLimits";
|
||||
|
||||
if (process.env.EMAIL_SERVICE) {
|
||||
EmailService.init(requireEnv('BREVO_API_KEY'));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
import { ProjectLimitModel } from '@schema/ProjectsLimits';
|
||||
import { ProjectLimitModel } from '@schema/project/ProjectsLimits';
|
||||
import { MAX_LOG_LIMIT_PERCENT } from '@data/broker/Limits';
|
||||
import { checkLimitsForEmail } from './EmailController';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { requireEnv } from '@utils/requireEnv';
|
||||
import { connectDatabase } from '@services/DatabaseService';
|
||||
import { RedisStreamService } from '@services/RedisStreamService';
|
||||
import { ProjectModel } from "@schema/ProjectSchema";
|
||||
import { ProjectModel } from "@schema/project/ProjectSchema";
|
||||
import { VisitModel } from "@schema/metrics/VisitSchema";
|
||||
import { SessionModel } from "@schema/metrics/SessionSchema";
|
||||
import { EventModel } from "@schema/metrics/EventSchema";
|
||||
@@ -10,8 +10,9 @@ import { lookup } from './lookup';
|
||||
import { UAParser } from 'ua-parser-js';
|
||||
import { checkLimits } from './LimitChecker';
|
||||
|
||||
import { ProjectLimitModel } from '@schema/ProjectsLimits';
|
||||
import { ProjectCountModel } from '@schema/ProjectsCounts';
|
||||
import { ProjectLimitModel } from '@schema/project/ProjectsLimits';
|
||||
import { ProjectCountModel } from '@schema/project/ProjectsCounts';
|
||||
|
||||
|
||||
connectDatabase(requireEnv('MONGO_CONNECTION_STRING'));
|
||||
main();
|
||||
|
||||
@@ -1,27 +1,10 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"module": "NodeNext",
|
||||
"target": "ESNext",
|
||||
"esModuleInterop": true,
|
||||
"outDir": "dist",
|
||||
"paths": {
|
||||
"@schema/*": [
|
||||
"../shared/schema/*"
|
||||
],
|
||||
"@services/*": [
|
||||
"../shared/services/*"
|
||||
],
|
||||
"@data/*": [
|
||||
"../shared/data/*"
|
||||
],
|
||||
"@functions/*": [
|
||||
"../shared/functions/*"
|
||||
],
|
||||
"@utils/*": [
|
||||
"../shared/utils/*"
|
||||
]
|
||||
}
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
|
||||
@@ -34,8 +34,7 @@ const snapshots = computed(() => {
|
||||
project_id: project.value?._id as any,
|
||||
_id: 'current_month' as any,
|
||||
name: 'Current month',
|
||||
from: fns.startOfMonth()
|
||||
new Date(Date.now() - 1000 * 60 * 60 * 24 * 30),
|
||||
from: new Date(Date.now() - 1000 * 60 * 60 * 24 * 30),
|
||||
to: new Date(Date.now()),
|
||||
color: '#00CC00'
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "nuxt-app",
|
||||
"name": "dashboard",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
@@ -14,29 +14,22 @@
|
||||
"docker-run": "docker run -p 3000:3000 litlyx-dashboard"
|
||||
},
|
||||
"dependencies": {
|
||||
"@getbrevo/brevo": "^2.2.0",
|
||||
"@nuxtjs/tailwindcss": "^6.12.0",
|
||||
"@supabase/supabase-js": "^2.45.4",
|
||||
"chart.js": "^3.9.1",
|
||||
"chartjs-chart-funnel": "^4.2.1",
|
||||
"chartjs-plugin-annotation": "^2.2.1",
|
||||
"date-fns": "^3.6.0",
|
||||
"dayjs": "^1.11.11",
|
||||
"google-auth-library": "^9.10.0",
|
||||
"googleapis": "^144.0.0",
|
||||
"highlight.js": "^11.10.0",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"litlyx-js": "^1.0.2",
|
||||
"mongoose": "^8.3.2",
|
||||
"nodemailer": "^6.9.13",
|
||||
"nuxt": "^3.11.2",
|
||||
"nuxt-vue3-google-signin": "^0.0.11",
|
||||
"openai": "^4.61.0",
|
||||
"pdfkit": "^0.15.0",
|
||||
"primevue": "^3.52.0",
|
||||
"redis": "^4.6.13",
|
||||
"sass": "^1.75.0",
|
||||
"stripe": "^15.8.0",
|
||||
"stripe": "^17.3.1",
|
||||
"v-calendar": "^3.1.2",
|
||||
"vue": "^3.4.21",
|
||||
"vue-chart-3": "^3.1.8",
|
||||
@@ -47,12 +40,9 @@
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^2.15.2",
|
||||
"@types/jsonwebtoken": "^9.0.6",
|
||||
"@types/markdown-it": "^14.1.2",
|
||||
"@types/nodemailer": "^6.4.15",
|
||||
"@types/pdfkit": "^0.13.4",
|
||||
"autoprefixer": "^10.4.19",
|
||||
"postcss": "^8.4.38",
|
||||
"tailwindcss": "^3.4.3",
|
||||
"vitest": "^1.6.0"
|
||||
"tailwindcss": "^3.4.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,23 +24,23 @@ import type { MetricsTimeline } from "~/server/api/metrics/[project_id]/timeline
|
||||
// getEndMonth: data => 23.59 dell ulrimo giorno del mese
|
||||
|
||||
|
||||
|
||||
|
||||
// Snapshot -> Current Week -> 11/11-00:00 - 17/11-23:59
|
||||
// Converti UTC UTENTE -> ISO
|
||||
|
||||
// Backend -> Prendi dati da ISO_A a ISO_B
|
||||
|
||||
|
||||
|
||||
// Funzioni da creare
|
||||
|
||||
// UTC TO ISO
|
||||
// Converte utc -> Iso
|
||||
// UTC TO ISO
|
||||
// UTC TO ISO Day
|
||||
|
||||
// UTC TO ISO Month
|
||||
|
||||
// UTC_IS_NEXT_DAY
|
||||
// True se il giorno passa a quello successivo
|
||||
|
||||
// UTC_IS_PREV_DAY
|
||||
// True se il giorno passa a quello precedente
|
||||
|
||||
|
||||
18
package.json
Normal file
18
package.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "litlyx",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {},
|
||||
"keywords": [],
|
||||
"author": "Emily",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@getbrevo/brevo": "^2.2.0",
|
||||
"mongoose": "^8.3.2",
|
||||
"redis": "^4.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"globs": "^0.1.4"
|
||||
}
|
||||
}
|
||||
11567
pnpm-lock.yaml
generated
Normal file
11567
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
6
pnpm-workspace.yaml
Normal file
6
pnpm-workspace.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
packages:
|
||||
# - "dashboard"
|
||||
- "producer"
|
||||
- "consumer"
|
||||
- "security"
|
||||
- "shared"
|
||||
2
shared/.gitignore
vendored
2
shared/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
node_modules
|
||||
package-lock.json
|
||||
@@ -1,11 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@getbrevo/brevo": "^2.2.0",
|
||||
"dayjs": "^1.11.11",
|
||||
"mongoose": "^8.4.0",
|
||||
"redis": "^4.6.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.12.13"
|
||||
}
|
||||
"name": "shared",
|
||||
"version": "1.0.0",
|
||||
"author": "Emily",
|
||||
"license": "MIT",
|
||||
"description": ""
|
||||
}
|
||||
1362
shared/pnpm-lock.yaml
generated
1362
shared/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,18 +0,0 @@
|
||||
import { model, Schema, Types } from 'mongoose';
|
||||
|
||||
export type TIntegrationsCredentials = {
|
||||
_id: Schema.Types.ObjectId,
|
||||
project_id: Schema.Types.ObjectId,
|
||||
supabase_url: string,
|
||||
supabase_anon_key: string,
|
||||
supabase_service_role_key: string,
|
||||
}
|
||||
|
||||
const IntegrationsCredentialsSchema = new Schema<TIntegrationsCredentials>({
|
||||
project_id: { type: Types.ObjectId, index: 1 },
|
||||
supabase_url: { type: String },
|
||||
supabase_anon_key: { type: String },
|
||||
supabase_service_role_key: { type: String },
|
||||
});
|
||||
|
||||
export const IntegrationsCredentialsModel = model<TIntegrationsCredentials>('integrations_credentials', IntegrationsCredentialsSchema);
|
||||
@@ -1,28 +0,0 @@
|
||||
import { model, Schema, Types } from 'mongoose';
|
||||
|
||||
export type TSupabaseIntegration = {
|
||||
_id: Schema.Types.ObjectId,
|
||||
project_id: Schema.Types.ObjectId,
|
||||
name: string,
|
||||
chart_type: string,
|
||||
table_name: string,
|
||||
xField: string,
|
||||
yMode: string,
|
||||
from: Date,
|
||||
to: Date,
|
||||
slice: string
|
||||
}
|
||||
|
||||
const SupabaseIntegrationSchema = new Schema<TSupabaseIntegration>({
|
||||
project_id: { type: Types.ObjectId, index: 1 },
|
||||
name: { type: String, required: true },
|
||||
chart_type: { type: String, required: true },
|
||||
table_name: { type: String, required: true },
|
||||
xField: { type: String, required: true },
|
||||
yMode: { type: String, required: true },
|
||||
from: { type: Date, required: true },
|
||||
to: { type: Date, required: true },
|
||||
slice: { type: String, required: true }
|
||||
});
|
||||
|
||||
export const SupabaseIntegrationModel = model<TSupabaseIntegration>('supabase_integrations', SupabaseIntegrationSchema);
|
||||
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"module": "NodeNext",
|
||||
"target": "ESNext"
|
||||
"target": "ESNext",
|
||||
"composite": true
|
||||
},
|
||||
"include": ["**/*.ts"],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
],
|
||||
}
|
||||
28
tsconfig.json
Normal file
28
tsconfig.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "NodeNext",
|
||||
"target": "ESNext",
|
||||
"moduleResolution": "nodenext",
|
||||
"paths": {
|
||||
"@schema/*": [
|
||||
"./shared/schema/*"
|
||||
],
|
||||
"@services/*": [
|
||||
"./shared/services/*"
|
||||
],
|
||||
"@data/*": [
|
||||
"./shared/data/*"
|
||||
],
|
||||
"@functions/*": [
|
||||
"./shared/functions/*"
|
||||
],
|
||||
"@utils/*": [
|
||||
"./shared/utils/*"
|
||||
]
|
||||
},
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user