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.
@@ -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,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"
@@ -0,0 +1,8 @@
1
+ generator client {
2
+ provider = "prisma-client"
3
+ output = "../src/generated/prisma"
4
+ }
5
+
6
+ datasource db {
7
+ provider = "postgresql"
8
+ }
@@ -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,9 @@
1
+ import "dotenv/config";
2
+ import { defineConfig } from "prisma/config";
3
+
4
+ export default defineConfig({
5
+ schema: "prisma/schema.prisma",
6
+ datasource: {
7
+ url: process.env.DATABASE_URL!,
8
+ },
9
+ });
@@ -0,0 +1,9 @@
1
+ declare global {
2
+ namespace Express {
3
+ interface Request {
4
+ userId?: string;
5
+ }
6
+ }
7
+ }
8
+
9
+ export {};
@@ -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,9 @@
1
+ import express from "express";
2
+
3
+ const server = express();
4
+
5
+ server.use(express.json());
6
+
7
+ server.listen(3000, () => {
8
+ console.log("API Iniciada");
9
+ });
@@ -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
+ }