vintasend 0.1.1 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/package.json +1 -1
  2. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/.dockerignore +1 -0
  3. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/.editorconfig +9 -0
  4. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/Dockerfile.dev +26 -0
  5. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/Dockerfile.notifications-worker +12 -4
  6. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/docker-compose.yml +12 -4
  7. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/migrations/20250213041915_initial/migration.sql +148 -0
  8. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/migrations/migration_lock.toml +3 -0
  9. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/next.config.ts +1 -0
  10. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/package-lock.json +281 -31
  11. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/package.json +16 -7
  12. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/schema.prisma +2 -1
  13. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/forgot-password/forgot-password-notification-context.ts +4 -1
  14. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/forgot-password/route.ts +3 -3
  15. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/login/route.ts +2 -2
  16. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/reset-password/route.ts +3 -3
  17. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/email-verification-notification-context.ts +24 -0
  18. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/route.ts +15 -4
  19. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/verify-email/route.ts +3 -3
  20. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/page.tsx +13 -1
  21. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/email-templates/auth/forgot-password/forgot-password-body.html.pug +39 -0
  22. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/email-templates/auth/forgot-password/forgot-password-subject.txt.pug +1 -0
  23. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/email-templates/auth/verify-email/verify-email-body.html.pug +40 -0
  24. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/email-templates/auth/verify-email/verify-email-subject.txt.pug +1 -0
  25. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/notifications-with-queue.ts +4 -4
  26. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/notifications.ts +2 -0
  27. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/temporal-queue-service.ts +6 -3
  28. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/temporal.ts +14 -0
  29. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/activities.ts +2 -4
  30. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/config.ts +4 -0
  31. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/worker.ts +14 -7
  32. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/temporal-config/dynamicconfig/development.yml +6 -0
  33. package/src/examples/nextjs-prisma-nodemailer-pug-temporal/tsconfig.json +2 -2
  34. package/src/implementations/vintasend-nodemailer/package.json +2 -2
  35. package/src/implementations/vintasend-prisma/package.json +2 -2
  36. package/src/implementations/vintasend-prisma/prisma-notification-backend.ts +1 -1
  37. package/src/implementations/vintasend-pug/package.json +2 -2
  38. package/src/implementations/vintasend-winston/package.json +2 -2
  39. package/src/services/notification-service.ts +70 -26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vintasend",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "scripts": {
5
5
  "lint": "biome check .",
6
6
  "format": "biome format .",
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [{src,scripts}/**.{ts,json,js}]
4
+ end_of_line = crlf
5
+ charset = utf-8
6
+ trim_trailing_whitespace = true
7
+ insert_final_newline = true
8
+ indent_style = space
9
+ indent_size = 2
@@ -0,0 +1,26 @@
1
+ FROM node:18-bullseye-slim
2
+
3
+ RUN apt-get update -y && \
4
+ apt-get install -y openssl && \
5
+ apt-get clean && \
6
+ rm -rf /var/lib/apt/lists/*
7
+
8
+ WORKDIR /app
9
+
10
+ # Copy dependency definitions
11
+ COPY package*.json ./
12
+
13
+ # Install dependencies
14
+ RUN npm install
15
+
16
+ # Copy the rest of the application code
17
+ COPY . .
18
+
19
+ # Generate prisma client
20
+ RUN npm run prisma -- generate
21
+
22
+ # Expose port 3000
23
+ EXPOSE 3000
24
+
25
+ # Start the app
26
+ CMD [ "npm", "run", "dev" ]
@@ -1,5 +1,12 @@
1
+ FROM node:18-slim
1
2
 
2
- FROM node:18-alpine
3
+ # Install required system dependencies
4
+ RUN apt-get update && \
5
+ apt-get install -y --no-install-recommends \
6
+ build-essential \
7
+ python3 \
8
+ openssl && \
9
+ rm -rf /var/lib/apt/lists/*
3
10
 
4
11
  WORKDIR /app
5
12
 
@@ -9,11 +16,12 @@ COPY package*.json ./
9
16
  # Install dependencies
10
17
  RUN npm install
11
18
 
19
+
12
20
  # Copy the rest of the application code
13
21
  COPY . .
14
22
 
15
- # Build the application
16
- RUN npm run build
23
+ # Generate prisma client
24
+ RUN npm run prisma -- generate
17
25
 
18
26
  # Start the Temporal worker
19
- CMD [ "npm", "run", "notifications-worker" ]
27
+ CMD [ "npx", "tsx", "src/workers/notifications/worker.ts" ]
@@ -1,20 +1,22 @@
1
- version: '3.8'
2
1
  services:
3
2
  app:
4
3
  build:
5
4
  context: .
6
- dockerfile: Dockerfile
5
+ dockerfile: Dockerfile.dev
7
6
  ports:
8
7
  - "3000:3000"
9
8
  environment:
10
9
  - DATABASE_URL=postgresql://postgres:postgres@postgres:5432/app_db?schema=public
11
10
  - MAIL_HOST=mailpit
12
11
  - MAIL_PORT=1025
12
+ - NODE_ENV=development
13
13
  depends_on:
14
14
  - postgres
15
15
  - mailpit
16
16
  volumes:
17
17
  - ./:/app
18
+ - /app/node_modules
19
+ - app_node_modules:/app/node_modules
18
20
 
19
21
  worker:
20
22
  build:
@@ -27,6 +29,8 @@ services:
27
29
  - mailpit
28
30
  volumes:
29
31
  - ./:/app
32
+ - /app/node_modules
33
+ - worker_node_modules:/app/node_modules
30
34
 
31
35
  temporal:
32
36
  image: temporalio/auto-setup:1.20.0
@@ -38,10 +42,12 @@ services:
38
42
  - DB_PORT=5432
39
43
  - POSTGRES_USER=temporal
40
44
  - POSTGRES_PWD=temporal
41
- - POSTGRES_SEEDS=temporal-postgresql:5432
42
- - DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development.yaml
45
+ - POSTGRES_SEEDS=temporal-postgresql
46
+ - DYNAMIC_CONFIG_FILE_PATH=/etc/temporal/config/dynamicconfig/development.yml
43
47
  depends_on:
44
48
  - temporal-postgresql
49
+ volumes:
50
+ - ./temporal-config/dynamicconfig:/etc/temporal/config/dynamicconfig
45
51
 
46
52
  temporal-postgresql:
47
53
  image: postgres:13
@@ -84,3 +90,5 @@ services:
84
90
  volumes:
85
91
  pgdata:
86
92
  temporal-pgdata:
93
+ app_node_modules:
94
+ worker_node_modules:
@@ -0,0 +1,148 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "TokenType" AS ENUM ('EMAIL_VERIFICATION', 'PASSWORD_RESET');
3
+
4
+ -- CreateEnum
5
+ CREATE TYPE "NotificationType" AS ENUM ('EMAIL', 'PUSH', 'SMS', 'IN_APP');
6
+
7
+ -- CreateEnum
8
+ CREATE TYPE "NotificationStatus" AS ENUM ('PENDING_SEND', 'SENT', 'FAILED', 'READ', 'CANCELLED');
9
+
10
+ -- CreateTable
11
+ CREATE TABLE "User" (
12
+ "id" SERIAL NOT NULL,
13
+ "email" TEXT NOT NULL,
14
+ "password" TEXT NOT NULL,
15
+ "firstName" TEXT,
16
+ "lastName" TEXT,
17
+ "isEmailVerified" BOOLEAN NOT NULL DEFAULT false,
18
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
19
+ "updatedAt" TIMESTAMP(3) NOT NULL,
20
+
21
+ CONSTRAINT "User_pkey" PRIMARY KEY ("id")
22
+ );
23
+
24
+ -- CreateTable
25
+ CREATE TABLE "Token" (
26
+ "id" SERIAL NOT NULL,
27
+ "token" TEXT NOT NULL,
28
+ "type" "TokenType" NOT NULL,
29
+ "expiresAt" TIMESTAMP(3) NOT NULL,
30
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
31
+ "userId" INTEGER NOT NULL,
32
+
33
+ CONSTRAINT "Token_pkey" PRIMARY KEY ("id")
34
+ );
35
+
36
+ -- CreateTable
37
+ CREATE TABLE "Permission" (
38
+ "id" SERIAL NOT NULL,
39
+ "name" TEXT NOT NULL,
40
+ "description" TEXT,
41
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
42
+ "updatedAt" TIMESTAMP(3) NOT NULL,
43
+
44
+ CONSTRAINT "Permission_pkey" PRIMARY KEY ("id")
45
+ );
46
+
47
+ -- CreateTable
48
+ CREATE TABLE "Role" (
49
+ "id" SERIAL NOT NULL,
50
+ "name" TEXT NOT NULL,
51
+ "description" TEXT,
52
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
53
+ "updatedAt" TIMESTAMP(3) NOT NULL,
54
+
55
+ CONSTRAINT "Role_pkey" PRIMARY KEY ("id")
56
+ );
57
+
58
+ -- CreateTable
59
+ CREATE TABLE "Notification" (
60
+ "id" SERIAL NOT NULL,
61
+ "userId" INTEGER NOT NULL,
62
+ "notificationType" "NotificationType" NOT NULL,
63
+ "title" TEXT,
64
+ "bodyTemplate" TEXT NOT NULL,
65
+ "contextName" TEXT NOT NULL,
66
+ "contextParameters" JSONB NOT NULL DEFAULT '{}',
67
+ "sendAfter" TIMESTAMP(3),
68
+ "subjectTemplate" TEXT,
69
+ "extraParams" JSONB,
70
+ "status" "NotificationStatus" NOT NULL DEFAULT 'PENDING_SEND',
71
+ "contextUsed" JSONB,
72
+ "adapterUsed" TEXT,
73
+ "sentAt" TIMESTAMP(3),
74
+ "readAt" TIMESTAMP(3),
75
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
76
+ "updatedAt" TIMESTAMP(3) NOT NULL,
77
+
78
+ CONSTRAINT "Notification_pkey" PRIMARY KEY ("id")
79
+ );
80
+
81
+ -- CreateTable
82
+ CREATE TABLE "_UserToPermission" (
83
+ "A" INTEGER NOT NULL,
84
+ "B" INTEGER NOT NULL,
85
+
86
+ CONSTRAINT "_UserToPermission_AB_pkey" PRIMARY KEY ("A","B")
87
+ );
88
+
89
+ -- CreateTable
90
+ CREATE TABLE "_RoleToPermission" (
91
+ "A" INTEGER NOT NULL,
92
+ "B" INTEGER NOT NULL,
93
+
94
+ CONSTRAINT "_RoleToPermission_AB_pkey" PRIMARY KEY ("A","B")
95
+ );
96
+
97
+ -- CreateTable
98
+ CREATE TABLE "_UserToRole" (
99
+ "A" INTEGER NOT NULL,
100
+ "B" INTEGER NOT NULL,
101
+
102
+ CONSTRAINT "_UserToRole_AB_pkey" PRIMARY KEY ("A","B")
103
+ );
104
+
105
+ -- CreateIndex
106
+ CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
107
+
108
+ -- CreateIndex
109
+ CREATE UNIQUE INDEX "Token_token_key" ON "Token"("token");
110
+
111
+ -- CreateIndex
112
+ CREATE UNIQUE INDEX "Permission_name_key" ON "Permission"("name");
113
+
114
+ -- CreateIndex
115
+ CREATE UNIQUE INDEX "Role_name_key" ON "Role"("name");
116
+
117
+ -- CreateIndex
118
+ CREATE INDEX "_UserToPermission_B_index" ON "_UserToPermission"("B");
119
+
120
+ -- CreateIndex
121
+ CREATE INDEX "_RoleToPermission_B_index" ON "_RoleToPermission"("B");
122
+
123
+ -- CreateIndex
124
+ CREATE INDEX "_UserToRole_B_index" ON "_UserToRole"("B");
125
+
126
+ -- AddForeignKey
127
+ ALTER TABLE "Token" ADD CONSTRAINT "Token_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
128
+
129
+ -- AddForeignKey
130
+ ALTER TABLE "Notification" ADD CONSTRAINT "Notification_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
131
+
132
+ -- AddForeignKey
133
+ ALTER TABLE "_UserToPermission" ADD CONSTRAINT "_UserToPermission_A_fkey" FOREIGN KEY ("A") REFERENCES "Permission"("id") ON DELETE CASCADE ON UPDATE CASCADE;
134
+
135
+ -- AddForeignKey
136
+ ALTER TABLE "_UserToPermission" ADD CONSTRAINT "_UserToPermission_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
137
+
138
+ -- AddForeignKey
139
+ ALTER TABLE "_RoleToPermission" ADD CONSTRAINT "_RoleToPermission_A_fkey" FOREIGN KEY ("A") REFERENCES "Permission"("id") ON DELETE CASCADE ON UPDATE CASCADE;
140
+
141
+ -- AddForeignKey
142
+ ALTER TABLE "_RoleToPermission" ADD CONSTRAINT "_RoleToPermission_B_fkey" FOREIGN KEY ("B") REFERENCES "Role"("id") ON DELETE CASCADE ON UPDATE CASCADE;
143
+
144
+ -- AddForeignKey
145
+ ALTER TABLE "_UserToRole" ADD CONSTRAINT "_UserToRole_A_fkey" FOREIGN KEY ("A") REFERENCES "Role"("id") ON DELETE CASCADE ON UPDATE CASCADE;
146
+
147
+ -- AddForeignKey
148
+ ALTER TABLE "_UserToRole" ADD CONSTRAINT "_UserToRole_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,3 @@
1
+ # Please do not edit this file manually
2
+ # It should be added in your version-control system (e.g., Git)
3
+ provider = "postgresql"
@@ -2,6 +2,7 @@ import type { NextConfig } from "next";
2
2
 
3
3
  const nextConfig: NextConfig = {
4
4
  /* config options here */
5
+ transpilePackages: ['vintasend', 'vintasend-prisma', 'vintasend-pug', 'vintasend-nodemailer', 'vintasend-winston'],
5
6
  };
6
7
 
7
8
  export default nextConfig;