create-carlos 1.0.0
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/index.js +45 -0
- package/package.json +18 -0
- package/templates/api-template/.env.example +11 -0
- package/templates/api-template/.gitattributes +6 -0
- package/templates/api-template/docker-compose.yml +27 -0
- package/templates/api-template/package-lock.json +4491 -0
- package/templates/api-template/package.json +44 -0
- package/templates/api-template/prisma/migrations/migration_lock.toml +3 -0
- package/templates/api-template/prisma/schema.prisma +8 -0
- package/templates/api-template/prisma/seed.ts +41 -0
- package/templates/api-template/prisma7.config.ts +9 -0
- package/templates/api-template/src/@types/express/index.d.ts +9 -0
- package/templates/api-template/src/lib/R2Bucket.ts +10 -0
- package/templates/api-template/src/lib/redis.ts +19 -0
- package/templates/api-template/src/prisma/prisma.ts +11 -0
- package/templates/api-template/src/server.ts +9 -0
- package/templates/api-template/tsconfig.json +48 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "real-estate-system-api",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"dev:server": "tsx watch src/server.ts",
|
|
9
|
+
"db:generate": "prisma generate",
|
|
10
|
+
"db:panel": "prisma studio",
|
|
11
|
+
"db:pull": "prisma db pull",
|
|
12
|
+
"db:migrate": "prisma migrate dev",
|
|
13
|
+
"db:deploy": "prisma migrate deploy",
|
|
14
|
+
"db:seed": "tsx prisma/seed.ts"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"author": "",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/bcrypt": "^6.0.0",
|
|
22
|
+
"@types/express": "^5.0.6",
|
|
23
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
24
|
+
"@types/multer": "^2.2.0",
|
|
25
|
+
"@types/node": "^26.4.0",
|
|
26
|
+
"@types/pg": "^8.23.1",
|
|
27
|
+
"prisma": "^7.10.0",
|
|
28
|
+
"tsx": "^4.23.12",
|
|
29
|
+
"typescript": "^7.0.2"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@aws-sdk/client-s3": "^3.1124.0",
|
|
33
|
+
"@aws-sdk/s3-request-presigner": "^3.1124.0",
|
|
34
|
+
"@prisma/adapter-pg": "^7.10.0",
|
|
35
|
+
"@prisma/client": "^7.10.0",
|
|
36
|
+
"bcrypt": "^6.0.0",
|
|
37
|
+
"dotenv": "^17.4.2",
|
|
38
|
+
"express": "^5.2.1",
|
|
39
|
+
"ioredis": "^6.0.0",
|
|
40
|
+
"jsonwebtoken": "^9.0.3",
|
|
41
|
+
"multer": "^2.3.0",
|
|
42
|
+
"pg": "^8.23.0"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
import { PrismaPg } from "@prisma/adapter-pg";
|
|
3
|
+
import { PrismaClient } from "../src/generated/prisma/client.js";
|
|
4
|
+
import bcrypt from "bcrypt";
|
|
5
|
+
|
|
6
|
+
const adapter = new PrismaPg({
|
|
7
|
+
connectionString: process.env.DATABASE_URL!,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const prisma = new PrismaClient({
|
|
11
|
+
adapter,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
async function main() {
|
|
15
|
+
const password = await bcrypt.hash("123456", 10);
|
|
16
|
+
|
|
17
|
+
await prisma.user.upsert({
|
|
18
|
+
where: {
|
|
19
|
+
email: "admin@admin.com",
|
|
20
|
+
},
|
|
21
|
+
update: {},
|
|
22
|
+
create: {
|
|
23
|
+
email: "admin@admin.com",
|
|
24
|
+
username: "admin",
|
|
25
|
+
name: "Administrador",
|
|
26
|
+
password,
|
|
27
|
+
updatedAt: new Date(),
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
console.log("Usuário criado com sucesso");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
main()
|
|
35
|
+
.catch((error) => {
|
|
36
|
+
console.error(error);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
})
|
|
39
|
+
.finally(async () => {
|
|
40
|
+
await prisma.$disconnect();
|
|
41
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { S3Client } from "@aws-sdk/client-s3";
|
|
2
|
+
|
|
3
|
+
export const r2 = new S3Client({
|
|
4
|
+
region: "auto",
|
|
5
|
+
endpoint: `https://${process.env.R2_ACCOUNT_ID}.r2.cloudflarestorage.com`,
|
|
6
|
+
credentials: {
|
|
7
|
+
accessKeyId: process.env.R2_ACCESS_KEY_ID!,
|
|
8
|
+
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Redis from "ioredis";
|
|
2
|
+
|
|
3
|
+
const redisUrl = process.env.REDIS_URL;
|
|
4
|
+
|
|
5
|
+
if (!redisUrl) {
|
|
6
|
+
throw new Error("REDIS_URL is not defined in the environment variables.");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const redis = new Redis(redisUrl);
|
|
10
|
+
|
|
11
|
+
redis.on("connect", () => {
|
|
12
|
+
console.log("Connected to Redis");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
redis.on("error", (error) => {
|
|
16
|
+
console.error("Redis error:", error);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export default redis;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
import { PrismaPg } from "@prisma/adapter-pg";
|
|
3
|
+
import { PrismaClient } from "../generated/prisma/client.js";
|
|
4
|
+
|
|
5
|
+
const adapter = new PrismaPg({
|
|
6
|
+
connectionString: process.env.DATABASE_URL!,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const prisma = new PrismaClient({
|
|
10
|
+
adapter,
|
|
11
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// File Layout
|
|
5
|
+
// "rootDir": "./src",
|
|
6
|
+
// "outDir": "./dist",
|
|
7
|
+
|
|
8
|
+
// Environment Settings
|
|
9
|
+
// See also https://aka.ms/tsconfig/module
|
|
10
|
+
"module": "preserve",
|
|
11
|
+
"target": "esnext",
|
|
12
|
+
"types": [
|
|
13
|
+
"node"
|
|
14
|
+
],
|
|
15
|
+
// For nodejs:
|
|
16
|
+
// "lib": ["esnext"],
|
|
17
|
+
// "types": ["node"],
|
|
18
|
+
// and npm install -D @types/node
|
|
19
|
+
|
|
20
|
+
// Other Outputs
|
|
21
|
+
"sourceMap": true,
|
|
22
|
+
"declaration": true,
|
|
23
|
+
"declarationMap": true,
|
|
24
|
+
|
|
25
|
+
// Stricter Typechecking Options
|
|
26
|
+
"noUncheckedIndexedAccess": true,
|
|
27
|
+
"exactOptionalPropertyTypes": true,
|
|
28
|
+
|
|
29
|
+
// Style Options
|
|
30
|
+
// "noImplicitReturns": true,
|
|
31
|
+
// "noImplicitOverride": true,
|
|
32
|
+
// "noUnusedLocals": true,
|
|
33
|
+
// "noUnusedParameters": true,
|
|
34
|
+
// "noFallthroughCasesInSwitch": true,
|
|
35
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
36
|
+
|
|
37
|
+
// Recommended Options
|
|
38
|
+
"strict": true,
|
|
39
|
+
"jsx": "react-jsx",
|
|
40
|
+
"verbatimModuleSyntax": true,
|
|
41
|
+
"isolatedModules": true,
|
|
42
|
+
"noUncheckedSideEffectImports": true,
|
|
43
|
+
"moduleDetection": "force",
|
|
44
|
+
"skipLibCheck": true,
|
|
45
|
+
"moduleResolution": "bundler",
|
|
46
|
+
"resolveJsonModule": true,
|
|
47
|
+
}
|
|
48
|
+
}
|