create-apppaaaul 2.0.43 → 2.0.46
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.
- package/dist/templates/nextjs-ts-clean/project/eslint.config.mjs +6 -8
- package/dist/templates/nextjs-ts-clean/project/package.json +1 -1
- package/dist/templates/nextjs-ts-landing-prisma/project/eslint.config.mjs +6 -8
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/autoprefixer +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/autoprefixer.CMD +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/autoprefixer.ps1 +4 -4
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/bcrypt +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/bcrypt.CMD +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/bcrypt.ps1 +4 -4
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/eslint +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/eslint-config-prettier +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/eslint-config-prettier.CMD +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/eslint-config-prettier.ps1 +4 -4
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/eslint.CMD +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/eslint.ps1 +4 -4
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/next +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/next-sitemap +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/next-sitemap-cjs +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/next-sitemap-cjs.CMD +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/next-sitemap-cjs.ps1 +4 -4
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/next-sitemap.CMD +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/next-sitemap.ps1 +4 -4
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/next.CMD +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/next.ps1 +4 -4
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/prettier +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/prettier.CMD +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/prettier.ps1 +4 -4
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/prisma +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/prisma.CMD +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/prisma.ps1 +4 -4
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/tsc +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/tsc.CMD +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/tsc.ps1 +4 -4
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/tsserver +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/tsserver.CMD +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/tsserver.ps1 +4 -4
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/tsx +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/tsx.CMD +2 -2
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.bin/tsx.ps1 +4 -4
- package/dist/templates/nextjs-ts-landing-prisma/project/node_modules/.modules.yaml +29 -1
- package/dist/templates/nextjs-ts-landing-prisma/project/package.json +5 -3
- package/dist/templates/nextjs-ts-landing-prisma/project/pnpm-lock.yaml +158 -36
- package/dist/templates/nextjs-ts-landing-prisma/project/src/app/layout.tsx +0 -16
- package/dist/templates/nextjs-ts-landing-prisma/project/src/lib/auth.ts +5 -3
- package/dist/templates/nextjs-ts-landing-prisma/project/src/lib/db.ts +6 -24
- package/dist/templates/nextjs-ts-landing-prisma/project/src/lib/rate-limit.ts +107 -0
- package/dist/templates/nextjs-ts-landing-prisma/project/src/scripts/db-seed.ts +2 -5
- package/dist/templates/nextjs-ts-landing-prisma/project/tsconfig.json +19 -5
- package/package.json +1 -1
|
@@ -1,28 +1,10 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
import { PrismaPg } from '@prisma/adapter-pg'
|
|
1
3
|
import { PrismaClient } from "@prisma/client";
|
|
2
4
|
|
|
3
|
-
const
|
|
4
|
-
db: PrismaClient | undefined;
|
|
5
|
-
};
|
|
5
|
+
const connectionString = `${process.env.DATABASE_URL}`
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
return new PrismaClient({
|
|
10
|
-
log: [],
|
|
11
|
-
datasources: {
|
|
12
|
-
db: {
|
|
13
|
-
url: process.env.DATABASE_URL,
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
};
|
|
7
|
+
const adapter = new PrismaPg({ connectionString })
|
|
8
|
+
const db = new PrismaClient({ adapter })
|
|
18
9
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (process.env.NODE_ENV !== "production") globalForPrisma.db = db;
|
|
22
|
-
|
|
23
|
-
// Graceful shutdown handling
|
|
24
|
-
process.on("beforeExit", () => {
|
|
25
|
-
void db.$disconnect();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export default db;
|
|
10
|
+
export { db }
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rate Limiter simple basado en memoria
|
|
3
|
+
* Limita el número de solicitudes por identificador en una ventana de tiempo
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
interface RateLimitResult {
|
|
7
|
+
success: boolean;
|
|
8
|
+
remaining: number;
|
|
9
|
+
resetTime: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface RateLimitConfig {
|
|
13
|
+
maxRequests: number;
|
|
14
|
+
windowMs: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface RateLimitEntry {
|
|
18
|
+
count: number;
|
|
19
|
+
resetTime: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class RateLimiter {
|
|
23
|
+
private cache: Map<string, RateLimitEntry> = new Map();
|
|
24
|
+
private maxRequests: number;
|
|
25
|
+
private windowMs: number;
|
|
26
|
+
|
|
27
|
+
constructor(config: RateLimitConfig) {
|
|
28
|
+
this.maxRequests = config.maxRequests;
|
|
29
|
+
this.windowMs = config.windowMs;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
check(identifier: string): RateLimitResult {
|
|
33
|
+
const now = Date.now();
|
|
34
|
+
const entry = this.cache.get(identifier);
|
|
35
|
+
|
|
36
|
+
// Si no existe entrada o la ventana expiró, crear nueva
|
|
37
|
+
if (!entry || now >= entry.resetTime) {
|
|
38
|
+
const resetTime = now + this.windowMs;
|
|
39
|
+
this.cache.set(identifier, { count: 1, resetTime });
|
|
40
|
+
return {
|
|
41
|
+
success: true,
|
|
42
|
+
remaining: this.maxRequests - 1,
|
|
43
|
+
resetTime,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Si existe entrada y está dentro de la ventana
|
|
48
|
+
if (entry.count >= this.maxRequests) {
|
|
49
|
+
return {
|
|
50
|
+
success: false,
|
|
51
|
+
remaining: 0,
|
|
52
|
+
resetTime: entry.resetTime,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Incrementar contador
|
|
57
|
+
entry.count++;
|
|
58
|
+
this.cache.set(identifier, entry);
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
success: true,
|
|
62
|
+
remaining: this.maxRequests - entry.count,
|
|
63
|
+
resetTime: entry.resetTime,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
reset(identifier: string): void {
|
|
68
|
+
this.cache.delete(identifier);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Rate limiters predefinidos para diferentes casos de uso
|
|
74
|
+
*/
|
|
75
|
+
export const rateLimiters = {
|
|
76
|
+
// Rate limiter general para API
|
|
77
|
+
api: new RateLimiter({
|
|
78
|
+
maxRequests: 100,
|
|
79
|
+
windowMs: 60 * 1000, // 100 requests por minuto
|
|
80
|
+
}),
|
|
81
|
+
|
|
82
|
+
// Rate limiter para autenticación (más restrictivo)
|
|
83
|
+
auth: new RateLimiter({
|
|
84
|
+
maxRequests: 10,
|
|
85
|
+
windowMs: 60 * 1000, // 10 intentos por minuto
|
|
86
|
+
}),
|
|
87
|
+
|
|
88
|
+
// Rate limiter para operaciones sensibles
|
|
89
|
+
sensitive: new RateLimiter({
|
|
90
|
+
maxRequests: 5,
|
|
91
|
+
windowMs: 60 * 1000, // 5 por minuto
|
|
92
|
+
}),
|
|
93
|
+
|
|
94
|
+
// Rate limiter para búsquedas
|
|
95
|
+
search: new RateLimiter({
|
|
96
|
+
maxRequests: 30,
|
|
97
|
+
windowMs: 60 * 1000, // 30 por minuto
|
|
98
|
+
}),
|
|
99
|
+
|
|
100
|
+
// Rate limiter para uploads
|
|
101
|
+
upload: new RateLimiter({
|
|
102
|
+
maxRequests: 10,
|
|
103
|
+
windowMs: 60 * 1000, // 10 por minuto
|
|
104
|
+
}),
|
|
105
|
+
} as const;
|
|
106
|
+
|
|
107
|
+
export type RateLimitType = keyof typeof rateLimiters;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const prisma = new PrismaClient();
|
|
1
|
+
import { db } from "@/lib/db";
|
|
5
2
|
|
|
6
3
|
async function main() {
|
|
7
4
|
//Create database data
|
|
@@ -12,5 +9,5 @@ main().catch((error) => {
|
|
|
12
9
|
console.error(error);
|
|
13
10
|
process.exit(1);
|
|
14
11
|
}).finally(async () => {
|
|
15
|
-
await
|
|
12
|
+
await db.$disconnect();
|
|
16
13
|
});
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "es6",
|
|
4
|
-
"lib": [
|
|
4
|
+
"lib": [
|
|
5
|
+
"dom",
|
|
6
|
+
"dom.iterable",
|
|
7
|
+
"esnext"
|
|
8
|
+
],
|
|
5
9
|
"allowJs": true,
|
|
6
10
|
"skipLibCheck": true,
|
|
7
11
|
"strict": true,
|
|
@@ -11,7 +15,7 @@
|
|
|
11
15
|
"moduleResolution": "bundler",
|
|
12
16
|
"resolveJsonModule": true,
|
|
13
17
|
"isolatedModules": true,
|
|
14
|
-
"jsx": "
|
|
18
|
+
"jsx": "react-jsx",
|
|
15
19
|
"incremental": true,
|
|
16
20
|
"plugins": [
|
|
17
21
|
{
|
|
@@ -19,9 +23,19 @@
|
|
|
19
23
|
}
|
|
20
24
|
],
|
|
21
25
|
"paths": {
|
|
22
|
-
"@/*": [
|
|
26
|
+
"@/*": [
|
|
27
|
+
"./src/*"
|
|
28
|
+
]
|
|
23
29
|
}
|
|
24
30
|
},
|
|
25
|
-
"include": [
|
|
26
|
-
|
|
31
|
+
"include": [
|
|
32
|
+
"next-env.d.ts",
|
|
33
|
+
"**/*.ts",
|
|
34
|
+
"**/*.tsx",
|
|
35
|
+
".next/types/**/*.ts",
|
|
36
|
+
".next/dev/types/**/*.ts"
|
|
37
|
+
],
|
|
38
|
+
"exclude": [
|
|
39
|
+
"node_modules"
|
|
40
|
+
]
|
|
27
41
|
}
|