diff --git a/hono-prisma-postgres/.gitignore b/hono-prisma-postgres/.gitignore new file mode 100644 index 0000000..786e0d9 --- /dev/null +++ b/hono-prisma-postgres/.gitignore @@ -0,0 +1,3 @@ +# deps +node_modules/ +.env \ No newline at end of file diff --git a/hono-prisma-postgres/README.md b/hono-prisma-postgres/README.md new file mode 100644 index 0000000..4132c48 --- /dev/null +++ b/hono-prisma-postgres/README.md @@ -0,0 +1,162 @@ +# Hono - Prisma - Postgres Sample Application + +This is a simple Todo application built using **Hono**, **Prisma**, **PostgreSQL**, **JWT**, and **TypeScript**. The project also integrates with **Keploy** for recording and running test cases. The package manager used is **Bun**. + +## Features + +- User authentication with JWT +- CRUD operations for Todo items +- API testing with Keploy + +## Tech Stack + +- **Framework**: Hono +- **Database**: PostgreSQL +- **ORM**: Prisma +- **Authentication**: JWT +- **Language**: TypeScript +- **Package Manager**: Bun + +## API Endpoints + +### Auth Routes + +- `GET /` - Test response +- `POST /register` - Register a new user +- `POST /login` - Log in a user + +### Protected Todo Routes (require authentication) + +- `POST /todos` - Create a new todo +- `GET /todos` - Retrieve all todos +- `PUT /todos` - Update a todo +- `DELETE /todos` - Delete a todo + +## Setup Instructions + +### Prerequisites + +- Node.js (with Bun installed) +- PostgreSQL installed and running +- Prisma CLI installed globally (`npm install -g prisma`) +- Keploy installed (Follow [documentation](https://keploy.io/docs/server/installation/) for installation) + +### Steps to Run the Project + +1. **Clone the Repository** + + ```bash + git clone + cd + ``` + +2. **Install Dependencies** + Use the following command to install dependencies with Bun: + ```bash + bun install + ``` +3. **Setup `.env`** + Create a .env file and add your Postgres database url. following is an example url: + ```bash + DATABASE_URL="postgresql://postgres:password@localhost:5432/my_pgserver?schema=public" + ``` +4. **Setup Database** + Run the Prisma migration command to initialize the database schema: + + ```bash + npx prisma migrate dev --name init + ``` + +5. **Run the Application** + Start the application using the following command: + + ```bash + bun dev + ``` + + The application should now be running on the specified port. + +## Keploy Integration + +Keploy allows you to record and test API requests and responses. Follow the steps below to use Keploy with this project: + +### Recording Test Cases + +1. Start the Keploy server if it's not already running. +2. Record test cases using the following command: + ```bash + keploy record -c "bun dev" + ``` + This will record all API interactions. + +### Running Test Cases + +1. Once test cases are recorded, you can run them using the following command: + + ```bash + keploy test -c "bun dev" --delay 10 + ``` + + The `--delay` flag ensures Keploy has enough time to send API requests after the application starts. + +## Notes + +- Ensure your database is properly configured in the `prisma.schema` file and the environment variables are set. +- Use the `authMiddleware` to protect routes requiring user authentication. +- For CORS support, the application includes: + ```typescript + app.use("/*", cors()); + ``` + +## Common Issues + +## PrismaClientInitializationError with Keploy Recording + +When running Keploy record command with database interactions, you might encounter a PrismaClientInitializationError. This often occurs due to SSL connection issues with PostgreSQL. + +### Symptoms + +When executing the Keploy record command: + +```bash +keploy record -c "bun dev" +``` + +You might encounter database connectivity issues, particularly when making API calls that interact with the database. The PostgreSQL logs typically show SSL-related errors like: + +``` +2024-12-25 13:42:23.035 IST [123887] [unknown]@[unknown] LOG: could not accept SSL connection: EOF detected +2024-12-25 14:41:45.859 IST [172605] [unknown]@[unknown] LOG: could not accept SSL connection: EOF detected +``` + +### Resolution (Ubuntu/Linux) + +1. **Access PostgreSQL Configuration** + + ```bash + sudo nano /etc/postgresql/12/main/postgresql.conf + ``` + +2. **Modify SSL Settings** + + - Locate the SSL configuration line + - Change `ssl = on` to `ssl = off` + +3. **Restart PostgreSQL** + ```bash + sudo service postgresql restart + ``` + +### Important Security Note + +⚠️ Disabling SSL should only be done in development environments. For production deployments: + +- Keep SSL enabled +- Properly configure SSL certificates +- Follow security best practices for database connections + +### Additional Considerations + +- Make sure your database connection string in `.env` is properly configured +- If you're using a different PostgreSQL version, the configuration file path might vary +- Always backup your configuration files before making changes diff --git a/hono-prisma-postgres/bun.lockb b/hono-prisma-postgres/bun.lockb new file mode 100644 index 0000000..b8d486a Binary files /dev/null and b/hono-prisma-postgres/bun.lockb differ diff --git a/hono-prisma-postgres/index.ts b/hono-prisma-postgres/index.ts new file mode 100644 index 0000000..f67b2c6 --- /dev/null +++ b/hono-prisma-postgres/index.ts @@ -0,0 +1 @@ +console.log("Hello via Bun!"); \ No newline at end of file diff --git a/hono-prisma-postgres/keploy.yml b/hono-prisma-postgres/keploy.yml new file mode 100755 index 0000000..155e188 --- /dev/null +++ b/hono-prisma-postgres/keploy.yml @@ -0,0 +1,61 @@ +path: "" +appId: 0 +appName: hono-prisma-postgres +command: bun dev +templatize: + testSets: [] +port: 0 +dnsPort: 26789 +proxyPort: 16789 +debug: false +disableTele: false +disableANSI: false +containerName: "" +networkName: "" +buildDelay: 30 +test: + selectedTests: {} + globalNoise: + global: {} + test-sets: {} + delay: 5 + host: "" + port: 0 + apiTimeout: 5 + skipCoverage: false + coverageReportPath: "" + ignoreOrdering: true + mongoPassword: default@123 + language: "" + removeUnusedMocks: false + fallBackOnMiss: false + jacocoAgentPath: "" + basePath: "" + mocking: true + ignoredTests: {} + disableLineCoverage: false + disableMockUpload: true + useLocalMock: false + updateTemplate: false +record: + filters: [] + recordTimer: 0s +configPath: "" +bypassRules: [] +generateGithubActions: false +keployContainer: keploy-v2 +keployNetwork: keploy-network +cmdType: native +contract: + services: [] + tests: [] + path: "" + download: false + generate: false + driven: consumer + mappings: + servicesMapping: {} + self: "" +inCi: false + +# Visit [https://keploy.io/docs/running-keploy/configuration-file/] to learn about using keploy through configration file. diff --git a/hono-prisma-postgres/keploy/.gitignore b/hono-prisma-postgres/keploy/.gitignore new file mode 100644 index 0000000..5137843 --- /dev/null +++ b/hono-prisma-postgres/keploy/.gitignore @@ -0,0 +1,2 @@ + +/reports/ diff --git a/hono-prisma-postgres/keploy/test-set-0/mocks.yaml b/hono-prisma-postgres/keploy/test-set-0/mocks.yaml new file mode 100755 index 0000000..7405ea5 --- /dev/null +++ b/hono-prisma-postgres/keploy/test-set-0/mocks.yaml @@ -0,0 +1,873 @@ +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-0 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + length: 8 + payload: AAAACATSFi8= + ssl_request: + is_ssl: true + auth_type: 0 + postgresresponses: + - payload: Tg== + authentication_md5_password: + salt: [0, 0, 0, 0] + auth_type: 0 + reqtimestampmock: 2024-12-25T16:16:32.529030126+05:30 + restimestampmock: 2024-12-25T16:16:32.529913372+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-1 +spec: + metadata: + type: config + postgresrequests: + - identifier: StartupRequest + payload: AAAAVgADAABjbGllbnRfZW5jb2RpbmcAVVRGOAB1c2VyAHBvc3RncmVzAGRhdGFiYXNlAG15X3Bnc2VydmVyAHNlYXJjaF9wYXRoACJwdWJsaWMiAAA= + auth_type: 0 + postgresresponses: + - header: [R] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [159, 202, 61, 42] + msg_type: 82 + auth_type: 5 + reqtimestampmock: 2024-12-25T16:16:32.530482239+05:30 + restimestampmock: 2024-12-25T16:16:32.530514088+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-2 +spec: + metadata: + type: config + postgresrequests: + - header: [p] + identifier: ClientRequest + length: 8 + password_message: + password: md5efc5766644b2275657bb145aa7546ff2 + msg_type: 112 + auth_type: 0 + postgresresponses: + - header: [R, S, S, S, S, S, S, S, S, S, S, S, K, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + backend_key_data: + process_id: 259431 + secret_key: 3379224120 + parameter_status: + - name: application_name + value: "" + - name: client_encoding + value: UTF8 + - name: DateStyle + value: ISO, DMY + - name: integer_datetimes + value: "on" + - name: IntervalStyle + value: postgres + - name: is_superuser + value: "on" + - name: server_encoding + value: UTF8 + - name: server_version + value: 12.20 (Ubuntu 12.20-1.pgdg22.04+1) + - name: session_authorization + value: postgres + - name: standard_conforming_strings + value: "on" + - name: TimeZone + value: Asia/Kolkata + - name: TimeZone + value: Asia/Kolkata + - name: TimeZone + value: Asia/Kolkata + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:16:32.53127552+05:30 + restimestampmock: 2024-12-25T16:16:32.531331643+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-3 +spec: + metadata: + type: config + postgresrequests: + - header: [P, D] + identifier: ClientRequest + length: 8 + payload: UAAAAOlzMABTRUxFQ1QgInB1YmxpYyIuIlVzZXIiLiJpZCIsICJwdWJsaWMiLiJVc2VyIi4iZW1haWwiLCAicHVibGljIi4iVXNlciIuInBhc3N3b3JkIiwgInB1YmxpYyIuIlVzZXIiLiJjcmVhdGVkQXQiLCAicHVibGljIi4iVXNlciIuInVwZGF0ZWRBdCIgRlJPTSAicHVibGljIi4iVXNlciIgV0hFUkUgKCJwdWJsaWMiLiJVc2VyIi4iZW1haWwiID0gJDEgQU5EIDE9MSkgTElNSVQgJDIgT0ZGU0VUICQzAAAARAAAAAhTczAAUwAAAAQ= + describe: + object_type: 83 + name: s0 + parse: + - name: s0 + query: SELECT "public"."User"."id", "public"."User"."email", "public"."User"."password", "public"."User"."createdAt", "public"."User"."updatedAt" FROM "public"."User" WHERE ("public"."User"."email" = $1 AND 1=1) LIMIT $2 OFFSET $3 + parameter_oids: [] + msg_type: 68 + auth_type: 0 + postgresresponses: + - header: ["1", t, T, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + parameter_description: + parameteroids: + - 25 + - 20 + - 20 + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: id, table_oid: 59271, table_attribute_number: 1, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: email, table_oid: 59271, table_attribute_number: 2, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: password, table_oid: 59271, table_attribute_number: 3, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: createdAt, table_oid: 59271, table_attribute_number: 4, data_type_oid: 1114, data_type_size: 8, type_modifier: 3, format: 0}, {field_name: updatedAt, table_oid: 59271, table_attribute_number: 5, data_type_oid: 1114, data_type_size: 8, type_modifier: 3, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:16:32.534066067+05:30 + restimestampmock: 2024-12-25T16:16:32.534092756+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-4 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAEEAczAAAAMAAQABAAEAAwAAAA90ZXN0MkBnbWFpbC5jb20AAAAIAAAAAAAAAAEAAAAIAAAAAAAAAAAAAQABRQAAAAkAAAAAAFMAAAAE + bind: + - prepared_statement: s0 + parameter_format_codes: [1, 1, 1] + parameters: [[116, 101, 115, 116, 50, 64, 103, 109, 97, 105, 108, 46, 99, 111, 109], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 0 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:16:32.543053582+05:30 + restimestampmock: 2024-12-25T16:16:32.543099316+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-5 +spec: + metadata: + type: config + postgresrequests: + - header: [P, D] + identifier: ClientRequest + length: 8 + payload: UAAAAP1zMQBJTlNFUlQgSU5UTyAicHVibGljIi4iVXNlciIgKCJpZCIsImVtYWlsIiwicGFzc3dvcmQiLCJjcmVhdGVkQXQiLCJ1cGRhdGVkQXQiKSBWQUxVRVMgKCQxLCQyLCQzLCQ0LCQ1KSBSRVRVUk5JTkcgInB1YmxpYyIuIlVzZXIiLiJpZCIsICJwdWJsaWMiLiJVc2VyIi4iZW1haWwiLCAicHVibGljIi4iVXNlciIuInBhc3N3b3JkIiwgInB1YmxpYyIuIlVzZXIiLiJjcmVhdGVkQXQiLCAicHVibGljIi4iVXNlciIuInVwZGF0ZWRBdCIAAABEAAAACFNzMQBTAAAABA== + describe: + object_type: 83 + name: s1 + parse: + - name: s1 + query: INSERT INTO "public"."User" ("id","email","password","createdAt","updatedAt") VALUES ($1,$2,$3,$4,$5) RETURNING "public"."User"."id", "public"."User"."email", "public"."User"."password", "public"."User"."createdAt", "public"."User"."updatedAt" + parameter_oids: [] + msg_type: 68 + auth_type: 0 + postgresresponses: + - header: ["1", t, T, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + parameter_description: + parameteroids: + - 25 + - 25 + - 25 + - 1114 + - 1114 + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: id, table_oid: 59271, table_attribute_number: 1, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: email, table_oid: 59271, table_attribute_number: 2, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: password, table_oid: 59271, table_attribute_number: 3, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: createdAt, table_oid: 59271, table_attribute_number: 4, data_type_oid: 1114, data_type_size: 8, type_modifier: 3, format: 0}, {field_name: updatedAt, table_oid: 59271, table_attribute_number: 5, data_type_oid: 1114, data_type_size: 8, type_modifier: 3, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:16:32.590023808+05:30 + restimestampmock: 2024-12-25T16:16:32.590065024+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-6 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAK0AczEAAAUAAQABAAEAAQABAAUAAAAkODc4MmVmNjItN2ZmOC00NjcxLWIxYzEtODBmMzAwOTRlZTJlAAAAD3Rlc3QyQGdtYWlsLmNvbQAAADwkMmIkMTAkOUQ5b0doc21uekIwdlZXQTd6U0JBZTFDM1IubkJXVGJJVERXd1BhR09raVFXL1I5TGJ3OFMAAAAIAALNFLYozsgAAAAIAALNFLYozsgAAQABRQAAAAkAAAAAAFMAAAAE + bind: + - prepared_statement: s1 + parameter_format_codes: [1, 1, 1, 1, 1] + parameters: [[56, 55, 56, 50, 101, 102, 54, 50, 45, 55, 102, 102, 56, 45, 52, 54, 55, 49, 45, 98, 49, 99, 49, 45, 56, 48, 102, 51, 48, 48, 57, 52, 101, 101, 50, 101], [116, 101, 115, 116, 50, 64, 103, 109, 97, 105, 108, 46, 99, 111, 109], [36, 50, 98, 36, 49, 48, 36, 57, 68, 57, 111, 71, 104, 115, 109, 110, 122, 66, 48, 118, 86, 87, 65, 55, 122, 83, 66, 65, 101, 49, 67, 51, 82, 46, 110, 66, 87, 84, 98, 73, 84, 68, 87, 119, 80, 97, 71, 79, 107, 105, 81, 87, 47, 82, 57, 76, 98, 119, 56, 83], [0, 2, 205, 20, 182, 40, 206, 200], [0, 2, 205, 20, 182, 40, 206, 200]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: INSERT 0 1 + data_row: [{row_values: [8782ef62-7ff8-4671-b1c1-80f30094ee2e, test2@gmail.com, $2b$10$9D9oGhsmnzB0vVWA7zSBAe1C3R.nBWTbITDWwPaGOkiQW/R9Lbw8S, 'b64:AALNFLYozsg=', 'b64:AALNFLYozsg=']}] + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:16:32.591153789+05:30 + restimestampmock: 2024-12-25T16:16:32.591185146+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-7 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAEEAczAAAAMAAQABAAEAAwAAAA90ZXN0MkBnbWFpbC5jb20AAAAIAAAAAAAAAAEAAAAIAAAAAAAAAAAAAQABRQAAAAkAAAAAAFMAAAAE + bind: + - prepared_statement: s0 + parameter_format_codes: [1, 1, 1] + parameters: [[116, 101, 115, 116, 50, 64, 103, 109, 97, 105, 108, 46, 99, 111, 109], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: [8782ef62-7ff8-4671-b1c1-80f30094ee2e, test2@gmail.com, $2b$10$9D9oGhsmnzB0vVWA7zSBAe1C3R.nBWTbITDWwPaGOkiQW/R9Lbw8S, 'b64:AALNFLYozsg=', 'b64:AALNFLYozsg=']}] + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:16:44.742962567+05:30 + restimestampmock: 2024-12-25T16:16:44.74300244+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-8 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT 1 + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: ["1"]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: '?column?', table_oid: 0, table_attribute_number: 0, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:17:10.897667518+05:30 + restimestampmock: 2024-12-25T16:17:10.897716077+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-9 +spec: + metadata: + type: config + postgresrequests: + - header: [P, D] + identifier: ClientRequest + length: 8 + payload: UAAAAPJzMgBTRUxFQ1QgInB1YmxpYyIuIlRvZG8iLiJpZCIsICJwdWJsaWMiLiJUb2RvIi4idGl0bGUiLCAicHVibGljIi4iVG9kbyIuImNvbXBsZXRlZCIsICJwdWJsaWMiLiJUb2RvIi4idXNlcklkIiwgInB1YmxpYyIuIlRvZG8iLiJjcmVhdGVkQXQiLCAicHVibGljIi4iVG9kbyIuInVwZGF0ZWRBdCIgRlJPTSAicHVibGljIi4iVG9kbyIgV0hFUkUgInB1YmxpYyIuIlRvZG8iLiJ1c2VySWQiID0gJDEgT0ZGU0VUICQyAAAARAAAAAhTczIAUwAAAAQ= + describe: + object_type: 83 + name: s2 + parse: + - name: s2 + query: SELECT "public"."Todo"."id", "public"."Todo"."title", "public"."Todo"."completed", "public"."Todo"."userId", "public"."Todo"."createdAt", "public"."Todo"."updatedAt" FROM "public"."Todo" WHERE "public"."Todo"."userId" = $1 OFFSET $2 + parameter_oids: [] + msg_type: 68 + auth_type: 0 + postgresresponses: + - header: ["1", t, T, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + parameter_description: + parameteroids: + - 25 + - 20 + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: id, table_oid: 59280, table_attribute_number: 1, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: title, table_oid: 59280, table_attribute_number: 2, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: completed, table_oid: 59280, table_attribute_number: 3, data_type_oid: 16, data_type_size: 1, type_modifier: -1, format: 0}, {field_name: userId, table_oid: 59280, table_attribute_number: 4, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: createdAt, table_oid: 59280, table_attribute_number: 5, data_type_oid: 1114, data_type_size: 8, type_modifier: 3, format: 0}, {field_name: updatedAt, table_oid: 59280, table_attribute_number: 6, data_type_oid: 1114, data_type_size: 8, type_modifier: 3, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:17:10.898231967+05:30 + restimestampmock: 2024-12-25T16:17:10.898287839+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-10 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAEgAczIAAAIAAQABAAIAAAAkODc4MmVmNjItN2ZmOC00NjcxLWIxYzEtODBmMzAwOTRlZTJlAAAACAAAAAAAAAAAAAEAAUUAAAAJAAAAAABTAAAABA== + bind: + - prepared_statement: s2 + parameter_format_codes: [1, 1] + parameters: [[56, 55, 56, 50, 101, 102, 54, 50, 45, 55, 102, 102, 56, 45, 52, 54, 55, 49, 45, 98, 49, 99, 49, 45, 56, 48, 102, 51, 48, 48, 57, 52, 101, 101, 50, 101], [0, 0, 0, 0, 0, 0, 0, 0]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 0 + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:17:10.898567564+05:30 + restimestampmock: 2024-12-25T16:17:10.898598672+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-11 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT 1 + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: ["1"]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: '?column?', table_oid: 0, table_attribute_number: 0, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:17:30.130276584+05:30 + restimestampmock: 2024-12-25T16:17:30.130309385+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-12 +spec: + metadata: + type: config + postgresrequests: + - header: [P, D] + identifier: ClientRequest + length: 8 + payload: UAAAASVzMwBJTlNFUlQgSU5UTyAicHVibGljIi4iVG9kbyIgKCJpZCIsInRpdGxlIiwiY29tcGxldGVkIiwidXNlcklkIiwiY3JlYXRlZEF0IiwidXBkYXRlZEF0IikgVkFMVUVTICgkMSwkMiwkMywkNCwkNSwkNikgUkVUVVJOSU5HICJwdWJsaWMiLiJUb2RvIi4iaWQiLCAicHVibGljIi4iVG9kbyIuInRpdGxlIiwgInB1YmxpYyIuIlRvZG8iLiJjb21wbGV0ZWQiLCAicHVibGljIi4iVG9kbyIuInVzZXJJZCIsICJwdWJsaWMiLiJUb2RvIi4iY3JlYXRlZEF0IiwgInB1YmxpYyIuIlRvZG8iLiJ1cGRhdGVkQXQiAAAARAAAAAhTczMAUwAAAAQ= + describe: + object_type: 83 + name: s3 + parse: + - name: s3 + query: INSERT INTO "public"."Todo" ("id","title","completed","userId","createdAt","updatedAt") VALUES ($1,$2,$3,$4,$5,$6) RETURNING "public"."Todo"."id", "public"."Todo"."title", "public"."Todo"."completed", "public"."Todo"."userId", "public"."Todo"."createdAt", "public"."Todo"."updatedAt" + parameter_oids: [] + msg_type: 68 + auth_type: 0 + postgresresponses: + - header: ["1", t, T, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + parameter_description: + parameteroids: + - 25 + - 25 + - 16 + - 25 + - 1114 + - 1114 + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: id, table_oid: 59280, table_attribute_number: 1, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: title, table_oid: 59280, table_attribute_number: 2, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: completed, table_oid: 59280, table_attribute_number: 3, data_type_oid: 16, data_type_size: 1, type_modifier: -1, format: 0}, {field_name: userId, table_oid: 59280, table_attribute_number: 4, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: createdAt, table_oid: 59280, table_attribute_number: 5, data_type_oid: 1114, data_type_size: 8, type_modifier: 3, format: 0}, {field_name: updatedAt, table_oid: 59280, table_attribute_number: 6, data_type_oid: 1114, data_type_size: 8, type_modifier: 3, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:17:30.130723727+05:30 + restimestampmock: 2024-12-25T16:17:30.130756468+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-13 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAJgAczMAAAYAAQABAAEAAQABAAEABgAAACQ1Y2E4Zjk4MS1lMWM4LTRkYzktOTVjZS1hZjVkMzRiN2I5ZTMAAAALVGVzdCBUb2RvIDEAAAABAAAAACQ4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUAAAAIAALNFLmW0FAAAAAIAALNFLmW0FAAAQABRQAAAAkAAAAAAFMAAAAE + bind: + - prepared_statement: s3 + parameter_format_codes: [1, 1, 1, 1, 1, 1] + parameters: [[53, 99, 97, 56, 102, 57, 56, 49, 45, 101, 49, 99, 56, 45, 52, 100, 99, 57, 45, 57, 53, 99, 101, 45, 97, 102, 53, 100, 51, 52, 98, 55, 98, 57, 101, 51], [84, 101, 115, 116, 32, 84, 111, 100, 111, 32, 49], [0], [56, 55, 56, 50, 101, 102, 54, 50, 45, 55, 102, 102, 56, 45, 52, 54, 55, 49, 45, 98, 49, 99, 49, 45, 56, 48, 102, 51, 48, 48, 57, 52, 101, 101, 50, 101], [0, 2, 205, 20, 185, 150, 208, 80], [0, 2, 205, 20, 185, 150, 208, 80]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: INSERT 0 1 + data_row: [{row_values: [5ca8f981-e1c8-4dc9-95ce-af5d34b7b9e3, Test Todo 1, 'b64:AA==', 8782ef62-7ff8-4671-b1c1-80f30094ee2e, 'b64:AALNFLmW0FA=', 'b64:AALNFLmW0FA=']}] + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:17:30.140626757+05:30 + restimestampmock: 2024-12-25T16:17:30.140674856+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-14 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAJgAczMAAAYAAQABAAEAAQABAAEABgAAACQ2NGZkMTk4MC01MjU4LTQyNGMtOTFiNy0xZDA0YTU1MDQzMmQAAAALVGVzdCBUb2RvIDIAAAABAAAAACQ4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUAAAAIAALNFLplPBAAAAAIAALNFLplPBAAAQABRQAAAAkAAAAAAFMAAAAE + bind: + - prepared_statement: s3 + parameter_format_codes: [1, 1, 1, 1, 1, 1] + parameters: [[54, 52, 102, 100, 49, 57, 56, 48, 45, 53, 50, 53, 56, 45, 52, 50, 52, 99, 45, 57, 49, 98, 55, 45, 49, 100, 48, 52, 97, 53, 53, 48, 52, 51, 50, 100], [84, 101, 115, 116, 32, 84, 111, 100, 111, 32, 50], [0], [56, 55, 56, 50, 101, 102, 54, 50, 45, 55, 102, 102, 56, 45, 52, 54, 55, 49, 45, 98, 49, 99, 49, 45, 56, 48, 102, 51, 48, 48, 57, 52, 101, 101, 50, 101], [0, 2, 205, 20, 186, 101, 60, 16], [0, 2, 205, 20, 186, 101, 60, 16]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: INSERT 0 1 + data_row: [{row_values: [64fd1980-5258-424c-91b7-1d04a550432d, Test Todo 2, 'b64:AA==', 8782ef62-7ff8-4671-b1c1-80f30094ee2e, 'b64:AALNFLplPBA=', 'b64:AALNFLplPBA=']}] + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:17:43.664444677+05:30 + restimestampmock: 2024-12-25T16:17:43.664492786+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-15 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT 1 + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: ["1"]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: '?column?', table_oid: 0, table_attribute_number: 0, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:17:47.385896893+05:30 + restimestampmock: 2024-12-25T16:17:47.385947496+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-16 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAJgAczMAAAYAAQABAAEAAQABAAEABgAAACRjZmM4NjBhYS1iNWI0LTRlY2UtOTI2Ny1iMjdiOTliZWI1MWEAAAALVGVzdCBUb2RvIDMAAAABAAAAACQ4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUAAAAIAALNFLqeHpAAAAAIAALNFLqeHpAAAQABRQAAAAkAAAAAAFMAAAAE + bind: + - prepared_statement: s3 + parameter_format_codes: [1, 1, 1, 1, 1, 1] + parameters: [[99, 102, 99, 56, 54, 48, 97, 97, 45, 98, 53, 98, 52, 45, 52, 101, 99, 101, 45, 57, 50, 54, 55, 45, 98, 50, 55, 98, 57, 57, 98, 101, 98, 53, 49, 97], [84, 101, 115, 116, 32, 84, 111, 100, 111, 32, 51], [0], [56, 55, 56, 50, 101, 102, 54, 50, 45, 55, 102, 102, 56, 45, 52, 54, 55, 49, 45, 98, 49, 99, 49, 45, 56, 48, 102, 51, 48, 48, 57, 52, 101, 101, 50, 101], [0, 2, 205, 20, 186, 158, 30, 144], [0, 2, 205, 20, 186, 158, 30, 144]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: INSERT 0 1 + data_row: [{row_values: [cfc860aa-b5b4-4ece-9267-b27b99beb51a, Test Todo 3, 'b64:AA==', 8782ef62-7ff8-4671-b1c1-80f30094ee2e, 'b64:AALNFLqeHpA=', 'b64:AALNFLqeHpA=']}] + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:17:47.39489707+05:30 + restimestampmock: 2024-12-25T16:17:47.394986064+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-17 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT 1 + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: ["1"]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: '?column?', table_oid: 0, table_attribute_number: 0, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:18:40.249446701+05:30 + restimestampmock: 2024-12-25T16:18:40.249484992+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-18 +spec: + metadata: + type: config + postgresrequests: + - header: [P, D] + identifier: ClientRequest + length: 8 + payload: UAAAATBzNABVUERBVEUgInB1YmxpYyIuIlRvZG8iIFNFVCAidGl0bGUiID0gJDEsICJ1cGRhdGVkQXQiID0gJDIgV0hFUkUgKCJwdWJsaWMiLiJUb2RvIi4iaWQiID0gJDMgQU5EICJwdWJsaWMiLiJUb2RvIi4idXNlcklkIiA9ICQ0KSBSRVRVUk5JTkcgInB1YmxpYyIuIlRvZG8iLiJpZCIsICJwdWJsaWMiLiJUb2RvIi4idGl0bGUiLCAicHVibGljIi4iVG9kbyIuImNvbXBsZXRlZCIsICJwdWJsaWMiLiJUb2RvIi4idXNlcklkIiwgInB1YmxpYyIuIlRvZG8iLiJjcmVhdGVkQXQiLCAicHVibGljIi4iVG9kbyIuInVwZGF0ZWRBdCIAAABEAAAACFNzNABTAAAABA== + describe: + object_type: 83 + name: s4 + parse: + - name: s4 + query: UPDATE "public"."Todo" SET "title" = $1, "updatedAt" = $2 WHERE ("public"."Todo"."id" = $3 AND "public"."Todo"."userId" = $4) RETURNING "public"."Todo"."id", "public"."Todo"."title", "public"."Todo"."completed", "public"."Todo"."userId", "public"."Todo"."createdAt", "public"."Todo"."updatedAt" + parameter_oids: [] + msg_type: 68 + auth_type: 0 + postgresresponses: + - header: ["1", t, T, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + parameter_description: + parameteroids: + - 25 + - 1114 + - 25 + - 25 + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: id, table_oid: 59280, table_attribute_number: 1, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: title, table_oid: 59280, table_attribute_number: 2, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: completed, table_oid: 59280, table_attribute_number: 3, data_type_oid: 16, data_type_size: 1, type_modifier: -1, format: 0}, {field_name: userId, table_oid: 59280, table_attribute_number: 4, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: createdAt, table_oid: 59280, table_attribute_number: 5, data_type_oid: 1114, data_type_size: 8, type_modifier: 3, format: 0}, {field_name: updatedAt, table_oid: 59280, table_attribute_number: 6, data_type_oid: 1114, data_type_size: 8, type_modifier: 3, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:18:40.249821201+05:30 + restimestampmock: 2024-12-25T16:18:40.24985906+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-19 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAIsAczQAAAQAAQABAAEAAQAEAAAAE1Rlc3QgVG9kbyAzIFVwZGF0ZWQAAAAIAALNFL3EvqgAAAAkY2ZjODYwYWEtYjViNC00ZWNlLTkyNjctYjI3Yjk5YmViNTFhAAAAJDg3ODJlZjYyLTdmZjgtNDY3MS1iMWMxLTgwZjMwMDk0ZWUyZQABAAFFAAAACQAAAAAAUwAAAAQ= + bind: + - prepared_statement: s4 + parameter_format_codes: [1, 1, 1, 1] + parameters: [[84, 101, 115, 116, 32, 84, 111, 100, 111, 32, 51, 32, 85, 112, 100, 97, 116, 101, 100], [0, 2, 205, 20, 189, 196, 190, 168], [99, 102, 99, 56, 54, 48, 97, 97, 45, 98, 53, 98, 52, 45, 52, 101, 99, 101, 45, 57, 50, 54, 55, 45, 98, 50, 55, 98, 57, 57, 98, 101, 98, 53, 49, 97], [56, 55, 56, 50, 101, 102, 54, 50, 45, 55, 102, 102, 56, 45, 52, 54, 55, 49, 45, 98, 49, 99, 49, 45, 56, 48, 102, 51, 48, 48, 57, 52, 101, 101, 50, 101]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: UPDATE 1 + data_row: [{row_values: [cfc860aa-b5b4-4ece-9267-b27b99beb51a, Test Todo 3 Updated, 'b64:AA==', 8782ef62-7ff8-4671-b1c1-80f30094ee2e, 'b64:AALNFLqeHpA=', 'b64:AALNFL3Evqg=']}] + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:18:40.258614768+05:30 + restimestampmock: 2024-12-25T16:18:40.258667365+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-20 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAEgAczIAAAIAAQABAAIAAAAkODc4MmVmNjItN2ZmOC00NjcxLWIxYzEtODBmMzAwOTRlZTJlAAAACAAAAAAAAAAAAAEAAUUAAAAJAAAAAABTAAAABA== + bind: + - prepared_statement: s2 + parameter_format_codes: [1, 1] + parameters: [[56, 55, 56, 50, 101, 102, 54, 50, 45, 55, 102, 102, 56, 45, 52, 54, 55, 49, 45, 98, 49, 99, 49, 45, 56, 48, 102, 51, 48, 48, 57, 52, 101, 101, 50, 101], [0, 0, 0, 0, 0, 0, 0, 0]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", D, D, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 3 + data_row: [{row_values: [5ca8f981-e1c8-4dc9-95ce-af5d34b7b9e3, Test Todo 1, 'b64:AA==', 8782ef62-7ff8-4671-b1c1-80f30094ee2e, 'b64:AALNFLmW0FA=', 'b64:AALNFLmW0FA=']}, {row_values: [64fd1980-5258-424c-91b7-1d04a550432d, Test Todo 2, 'b64:AA==', 8782ef62-7ff8-4671-b1c1-80f30094ee2e, 'b64:AALNFLplPBA=', 'b64:AALNFLplPBA=']}, {row_values: [cfc860aa-b5b4-4ece-9267-b27b99beb51a, Test Todo 3 Updated, 'b64:AA==', 8782ef62-7ff8-4671-b1c1-80f30094ee2e, 'b64:AALNFLqeHpA=', 'b64:AALNFL3Evqg=']}] + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:18:44.916734341+05:30 + restimestampmock: 2024-12-25T16:18:44.916782921+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-21 +spec: + metadata: + type: config + postgresrequests: + - header: [Q] + identifier: ClientRequest + length: 8 + query: + string: SELECT 1 + msg_type: 81 + auth_type: 0 + postgresresponses: + - header: [T, D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: SELECT 1 + data_row: [{row_values: ["1"]}] + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: '?column?', table_oid: 0, table_attribute_number: 0, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:19:42.483036548+05:30 + restimestampmock: 2024-12-25T16:19:42.483074298+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-22 +spec: + metadata: + type: config + postgresrequests: + - header: [P, D] + identifier: ClientRequest + length: 8 + payload: UAAAARJzNQBERUxFVEUgRlJPTSAicHVibGljIi4iVG9kbyIgV0hFUkUgKCJwdWJsaWMiLiJUb2RvIi4iaWQiID0gJDEgQU5EICJwdWJsaWMiLiJUb2RvIi4idXNlcklkIiA9ICQyKSBSRVRVUk5JTkcgInB1YmxpYyIuIlRvZG8iLiJpZCIsICJwdWJsaWMiLiJUb2RvIi4idGl0bGUiLCAicHVibGljIi4iVG9kbyIuImNvbXBsZXRlZCIsICJwdWJsaWMiLiJUb2RvIi4idXNlcklkIiwgInB1YmxpYyIuIlRvZG8iLiJjcmVhdGVkQXQiLCAicHVibGljIi4iVG9kbyIuInVwZGF0ZWRBdCIAAABEAAAACFNzNQBTAAAABA== + describe: + object_type: 83 + name: s5 + parse: + - name: s5 + query: DELETE FROM "public"."Todo" WHERE ("public"."Todo"."id" = $1 AND "public"."Todo"."userId" = $2) RETURNING "public"."Todo"."id", "public"."Todo"."title", "public"."Todo"."completed", "public"."Todo"."userId", "public"."Todo"."createdAt", "public"."Todo"."updatedAt" + parameter_oids: [] + msg_type: 68 + auth_type: 0 + postgresresponses: + - header: ["1", t, T, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + parameter_description: + parameteroids: + - 25 + - 25 + ready_for_query: + txstatus: 73 + row_description: {fields: [{field_name: id, table_oid: 59280, table_attribute_number: 1, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: title, table_oid: 59280, table_attribute_number: 2, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: completed, table_oid: 59280, table_attribute_number: 3, data_type_oid: 16, data_type_size: 1, type_modifier: -1, format: 0}, {field_name: userId, table_oid: 59280, table_attribute_number: 4, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}, {field_name: createdAt, table_oid: 59280, table_attribute_number: 5, data_type_oid: 1114, data_type_size: 8, type_modifier: 3, format: 0}, {field_name: updatedAt, table_oid: 59280, table_attribute_number: 6, data_type_oid: 1114, data_type_size: 8, type_modifier: 3, format: 0}]} + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:19:42.483520958+05:30 + restimestampmock: 2024-12-25T16:19:42.483566643+05:30 +connectionId: "0" +--- +version: api.keploy.io/v1beta1 +kind: Postgres +name: mock-23 +spec: + metadata: + type: config + postgresrequests: + - header: [B, E] + identifier: ClientRequest + length: 8 + payload: QgAAAGQAczUAAAIAAQABAAIAAAAkNWNhOGY5ODEtZTFjOC00ZGM5LTk1Y2UtYWY1ZDM0YjdiOWUzAAAAJDg3ODJlZjYyLTdmZjgtNDY3MS1iMWMxLTgwZjMwMDk0ZWUyZQABAAFFAAAACQAAAAAAUwAAAAQ= + bind: + - prepared_statement: s5 + parameter_format_codes: [1, 1] + parameters: [[53, 99, 97, 56, 102, 57, 56, 49, 45, 101, 49, 99, 56, 45, 52, 100, 99, 57, 45, 57, 53, 99, 101, 45, 97, 102, 53, 100, 51, 52, 98, 55, 98, 57, 101, 51], [56, 55, 56, 50, 101, 102, 54, 50, 45, 55, 102, 102, 56, 45, 52, 54, 55, 49, 45, 98, 49, 99, 49, 45, 56, 48, 102, 51, 48, 48, 57, 52, 101, 101, 50, 101]] + result_format_codes: [1] + execute: + - {} + msg_type: 69 + auth_type: 0 + postgresresponses: + - header: ["2", D, C, Z] + identifier: ServerResponse + length: 8 + authentication_md5_password: + salt: [0, 0, 0, 0] + command_complete: + - command_tag_type: DELETE 1 + data_row: [{row_values: [5ca8f981-e1c8-4dc9-95ce-af5d34b7b9e3, Test Todo 1, 'b64:AA==', 8782ef62-7ff8-4671-b1c1-80f30094ee2e, 'b64:AALNFLmW0FA=', 'b64:AALNFLmW0FA=']}] + ready_for_query: + txstatus: 73 + msg_type: 90 + auth_type: 0 + reqtimestampmock: 2024-12-25T16:19:42.492366671+05:30 + restimestampmock: 2024-12-25T16:19:42.492422435+05:30 +connectionId: "0" diff --git a/hono-prisma-postgres/keploy/test-set-0/tests/test-1.yaml b/hono-prisma-postgres/keploy/test-set-0/tests/test-1.yaml new file mode 100755 index 0000000..895dff9 --- /dev/null +++ b/hono-prisma-postgres/keploy/test-set-0/tests/test-1.yaml @@ -0,0 +1,47 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-1 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/ + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Cache-Control: no-cache + Connection: keep-alive + Host: localhost:3000 + Postman-Token: 2bc09276-938d-4d5c-bb52-42ec955ad1d9 + User-Agent: PostmanRuntime/7.43.0 + body: "" + timestamp: 2024-12-25T16:16:12.580822546+05:30 + resp: + status_code: 200 + header: + Access-Control-Allow-Origin: '*' + Content-Length: "27" + Content-Type: application/json + Date: Wed, 25 Dec 2024 10:46:12 GMT + body: '{"message":"Hello, world!"}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-12-25T16:16:14.681431854+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1735123574 +curl: | + curl --request GET \ + --url http://localhost:3000/ \ + --header 'Postman-Token: 2bc09276-938d-4d5c-bb52-42ec955ad1d9' \ + --header 'Host: localhost:3000' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Connection: keep-alive' \ + --header 'User-Agent: PostmanRuntime/7.43.0' \ + --header 'Accept: */*' \ + --header 'Cache-Control: no-cache' \ diff --git a/hono-prisma-postgres/keploy/test-set-0/tests/test-10.yaml b/hono-prisma-postgres/keploy/test-set-0/tests/test-10.yaml new file mode 100755 index 0000000..58da951 --- /dev/null +++ b/hono-prisma-postgres/keploy/test-set-0/tests/test-10.yaml @@ -0,0 +1,51 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-10 +spec: + metadata: {} + req: + method: DELETE + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos/39a48e7e-4264-4c89-9b97-8b2e657e44be?id=5ca8f981-e1c8-4dc9-95ce-af5d34b7b9e3 + url_params: + id: 5ca8f981-e1c8-4dc9-95ce-af5d34b7b9e3 + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4 + Cache-Control: no-cache + Connection: keep-alive + Host: localhost:3000 + Postman-Token: 2a917ebb-1541-4649-bccb-488986fbcc82 + User-Agent: PostmanRuntime/7.43.0 + body: "" + timestamp: 2024-12-25T16:19:27.507041335+05:30 + resp: + status_code: 404 + header: + Access-Control-Allow-Origin: '*' + Content-Length: "13" + Content-Type: text/plain; charset=UTF-8 + Date: Wed, 25 Dec 2024 10:49:26 GMT + body: 404 Not Found + status_message: Not Found + proto_major: 0 + proto_minor: 0 + timestamp: 2024-12-25T16:19:29.527291359+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1735123769 +curl: | + curl --request DELETE \ + --url http://localhost:3000/todos/39a48e7e-4264-4c89-9b97-8b2e657e44be?id=5ca8f981-e1c8-4dc9-95ce-af5d34b7b9e3 \ + --header 'Host: localhost:3000' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Connection: keep-alive' \ + --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4' \ + --header 'User-Agent: PostmanRuntime/7.43.0' \ + --header 'Accept: */*' \ + --header 'Cache-Control: no-cache' \ + --header 'Postman-Token: 2a917ebb-1541-4649-bccb-488986fbcc82' \ diff --git a/hono-prisma-postgres/keploy/test-set-0/tests/test-11.yaml b/hono-prisma-postgres/keploy/test-set-0/tests/test-11.yaml new file mode 100755 index 0000000..e59da5f --- /dev/null +++ b/hono-prisma-postgres/keploy/test-set-0/tests/test-11.yaml @@ -0,0 +1,51 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-11 +spec: + metadata: {} + req: + method: DELETE + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos?id=5ca8f981-e1c8-4dc9-95ce-af5d34b7b9e3 + url_params: + id: 5ca8f981-e1c8-4dc9-95ce-af5d34b7b9e3 + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4 + Cache-Control: no-cache + Connection: keep-alive + Host: localhost:3000 + Postman-Token: 4c429b20-f5e3-4af1-a371-70729d7e8569 + User-Agent: PostmanRuntime/7.43.0 + body: "" + timestamp: 2024-12-25T16:19:42.480685433+05:30 + resp: + status_code: 200 + header: + Access-Control-Allow-Origin: '*' + Content-Length: "39" + Content-Type: application/json + Date: Wed, 25 Dec 2024 10:49:41 GMT + body: '{"message":"Todo deleted successfully"}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-12-25T16:19:44.5641867+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1735123784 +curl: | + curl --request DELETE \ + --url http://localhost:3000/todos?id=5ca8f981-e1c8-4dc9-95ce-af5d34b7b9e3 \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Connection: keep-alive' \ + --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4' \ + --header 'User-Agent: PostmanRuntime/7.43.0' \ + --header 'Accept: */*' \ + --header 'Cache-Control: no-cache' \ + --header 'Postman-Token: 4c429b20-f5e3-4af1-a371-70729d7e8569' \ + --header 'Host: localhost:3000' \ diff --git a/hono-prisma-postgres/keploy/test-set-0/tests/test-2.yaml b/hono-prisma-postgres/keploy/test-set-0/tests/test-2.yaml new file mode 100755 index 0000000..88fc941 --- /dev/null +++ b/hono-prisma-postgres/keploy/test-set-0/tests/test-2.yaml @@ -0,0 +1,55 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-2 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/register + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Cache-Control: no-cache + Connection: keep-alive + Content-Length: "63" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 6a7f4dd3-b1de-40fd-92eb-aef6f8b62447 + User-Agent: PostmanRuntime/7.43.0 + body: |- + { + "email" : "test2@gmail.com", + "password" : "test123" + } + timestamp: 2024-12-25T16:16:32.502757692+05:30 + resp: + status_code: 200 + header: + Access-Control-Allow-Origin: '*' + Content-Length: "181" + Content-Type: application/json + Date: Wed, 25 Dec 2024 10:46:32 GMT + body: '{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM1OTJ9.X8XPpKegGYNC-UQAK-NTpxYfmqfzeTjXdf3IDL8N7KA"}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-12-25T16:16:34.629022738+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1735123594 +curl: |- + curl --request POST \ + --url http://localhost:3000/register \ + --header 'Host: localhost:3000' \ + --header 'Content-Type: application/json' \ + --header 'Accept: */*' \ + --header 'User-Agent: PostmanRuntime/7.43.0' \ + --header 'Connection: keep-alive' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Cache-Control: no-cache' \ + --header 'Postman-Token: 6a7f4dd3-b1de-40fd-92eb-aef6f8b62447' \ + --data "{\n \"email\" : \"test2@gmail.com\",\n \"password\" : \"test123\"\n}" diff --git a/hono-prisma-postgres/keploy/test-set-0/tests/test-3.yaml b/hono-prisma-postgres/keploy/test-set-0/tests/test-3.yaml new file mode 100755 index 0000000..c10c90f --- /dev/null +++ b/hono-prisma-postgres/keploy/test-set-0/tests/test-3.yaml @@ -0,0 +1,55 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-3 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/login + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Cache-Control: no-cache + Connection: keep-alive + Content-Length: "63" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 49a8e6ce-f6e3-4149-9be2-dcdbe0df1969 + User-Agent: PostmanRuntime/7.43.0 + body: |- + { + "email" : "test2@gmail.com", + "password" : "test123" + } + timestamp: 2024-12-25T16:16:44.740088526+05:30 + resp: + status_code: 200 + header: + Access-Control-Allow-Origin: '*' + Content-Length: "181" + Content-Type: application/json + Date: Wed, 25 Dec 2024 10:46:44 GMT + body: '{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4"}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-12-25T16:16:46.858224148+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1735123606 +curl: |- + curl --request POST \ + --url http://localhost:3000/login \ + --header 'User-Agent: PostmanRuntime/7.43.0' \ + --header 'Connection: keep-alive' \ + --header 'Postman-Token: 49a8e6ce-f6e3-4149-9be2-dcdbe0df1969' \ + --header 'Host: localhost:3000' \ + --header 'Cache-Control: no-cache' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Content-Type: application/json' \ + --header 'Accept: */*' \ + --data "{\n \"email\" : \"test2@gmail.com\",\n \"password\" : \"test123\"\n}" diff --git a/hono-prisma-postgres/keploy/test-set-0/tests/test-4.yaml b/hono-prisma-postgres/keploy/test-set-0/tests/test-4.yaml new file mode 100755 index 0000000..5708fac --- /dev/null +++ b/hono-prisma-postgres/keploy/test-set-0/tests/test-4.yaml @@ -0,0 +1,49 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-4 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4 + Cache-Control: no-cache + Connection: keep-alive + Host: localhost:3000 + Postman-Token: 79be9af7-4541-4bb6-a40e-777b8807fab5 + User-Agent: PostmanRuntime/7.43.0 + body: "" + timestamp: 2024-12-25T16:17:10.893764413+05:30 + resp: + status_code: 200 + header: + Access-Control-Allow-Origin: '*' + Content-Length: "2" + Content-Type: application/json + Date: Wed, 25 Dec 2024 10:47:10 GMT + body: '[]' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-12-25T16:17:12.919121183+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1735123632 +curl: | + curl --request GET \ + --url http://localhost:3000/todos \ + --header 'User-Agent: PostmanRuntime/7.43.0' \ + --header 'Accept: */*' \ + --header 'Cache-Control: no-cache' \ + --header 'Postman-Token: 79be9af7-4541-4bb6-a40e-777b8807fab5' \ + --header 'Host: localhost:3000' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Connection: keep-alive' \ + --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4' \ diff --git a/hono-prisma-postgres/keploy/test-set-0/tests/test-5.yaml b/hono-prisma-postgres/keploy/test-set-0/tests/test-5.yaml new file mode 100755 index 0000000..571aec5 --- /dev/null +++ b/hono-prisma-postgres/keploy/test-set-0/tests/test-5.yaml @@ -0,0 +1,58 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-5 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4 + Cache-Control: no-cache + Connection: keep-alive + Content-Length: "31" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: f8aed2c4-e8d5-40f7-8253-efca5a1f48d4 + User-Agent: PostmanRuntime/7.43.0 + body: |- + { + "title" : "Test Todo 1" + } + timestamp: 2024-12-25T16:17:30.127492169+05:30 + resp: + status_code: 200 + header: + Access-Control-Allow-Origin: '*' + Content-Length: "211" + Content-Type: application/json + Date: Wed, 25 Dec 2024 10:47:29 GMT + body: '{"id":"5ca8f981-e1c8-4dc9-95ce-af5d34b7b9e3","title":"Test Todo 1","completed":false,"userId":"8782ef62-7ff8-4671-b1c1-80f30094ee2e","createdAt":"2024-12-25T10:47:30.130Z","updatedAt":"2024-12-25T10:47:30.130Z"}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-12-25T16:17:32.161502373+05:30 + objects: [] + assertions: + noise: + body.createdAt: [] + body.updatedAt: [] + header.Date: [] + created: 1735123652 +curl: |- + curl --request POST \ + --url http://localhost:3000/todos \ + --header 'Content-Type: application/json' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Cache-Control: no-cache' \ + --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4' \ + --header 'User-Agent: PostmanRuntime/7.43.0' \ + --header 'Connection: keep-alive' \ + --header 'Accept: */*' \ + --header 'Host: localhost:3000' \ + --header 'Postman-Token: f8aed2c4-e8d5-40f7-8253-efca5a1f48d4' \ + --data "{\n \"title\" : \"Test Todo 1\"\n}" diff --git a/hono-prisma-postgres/keploy/test-set-0/tests/test-6.yaml b/hono-prisma-postgres/keploy/test-set-0/tests/test-6.yaml new file mode 100755 index 0000000..af00ec9 --- /dev/null +++ b/hono-prisma-postgres/keploy/test-set-0/tests/test-6.yaml @@ -0,0 +1,58 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-6 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4 + Cache-Control: no-cache + Connection: keep-alive + Content-Length: "31" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 0d90abf1-c589-4a4a-9bc9-9bd99d785e44 + User-Agent: PostmanRuntime/7.43.0 + body: |- + { + "title" : "Test Todo 2" + } + timestamp: 2024-12-25T16:17:43.655152682+05:30 + resp: + status_code: 200 + header: + Access-Control-Allow-Origin: '*' + Content-Length: "211" + Content-Type: application/json + Date: Wed, 25 Dec 2024 10:47:43 GMT + body: '{"id":"64fd1980-5258-424c-91b7-1d04a550432d","title":"Test Todo 2","completed":false,"userId":"8782ef62-7ff8-4671-b1c1-80f30094ee2e","createdAt":"2024-12-25T10:47:43.658Z","updatedAt":"2024-12-25T10:47:43.658Z"}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-12-25T16:17:45.693084387+05:30 + objects: [] + assertions: + noise: + body.createdAt: [] + body.updatedAt: [] + header.Date: [] + created: 1735123665 +curl: |- + curl --request POST \ + --url http://localhost:3000/todos \ + --header 'Connection: keep-alive' \ + --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4' \ + --header 'Cache-Control: no-cache' \ + --header 'Accept: */*' \ + --header 'Postman-Token: 0d90abf1-c589-4a4a-9bc9-9bd99d785e44' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Content-Type: application/json' \ + --header 'User-Agent: PostmanRuntime/7.43.0' \ + --header 'Host: localhost:3000' \ + --data "{\n \"title\" : \"Test Todo 2\"\n}" diff --git a/hono-prisma-postgres/keploy/test-set-0/tests/test-7.yaml b/hono-prisma-postgres/keploy/test-set-0/tests/test-7.yaml new file mode 100755 index 0000000..40d2b93 --- /dev/null +++ b/hono-prisma-postgres/keploy/test-set-0/tests/test-7.yaml @@ -0,0 +1,58 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-7 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4 + Cache-Control: no-cache + Connection: keep-alive + Content-Length: "31" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: a67092af-5dff-40fe-b0e6-a4b3a576e4bd + User-Agent: PostmanRuntime/7.43.0 + body: |- + { + "title" : "Test Todo 3" + } + timestamp: 2024-12-25T16:17:47.383713524+05:30 + resp: + status_code: 200 + header: + Access-Control-Allow-Origin: '*' + Content-Length: "211" + Content-Type: application/json + Date: Wed, 25 Dec 2024 10:47:46 GMT + body: '{"id":"cfc860aa-b5b4-4ece-9267-b27b99beb51a","title":"Test Todo 3","completed":false,"userId":"8782ef62-7ff8-4671-b1c1-80f30094ee2e","createdAt":"2024-12-25T10:47:47.386Z","updatedAt":"2024-12-25T10:47:47.386Z"}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-12-25T16:17:49.401329015+05:30 + objects: [] + assertions: + noise: + body.createdAt: [] + body.updatedAt: [] + header.Date: [] + created: 1735123669 +curl: |- + curl --request POST \ + --url http://localhost:3000/todos \ + --header 'Postman-Token: a67092af-5dff-40fe-b0e6-a4b3a576e4bd' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:3000' \ + --header 'Accept: */*' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'User-Agent: PostmanRuntime/7.43.0' \ + --header 'Cache-Control: no-cache' \ + --header 'Connection: keep-alive' \ + --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4' \ + --data "{\n \"title\" : \"Test Todo 3\"\n}" diff --git a/hono-prisma-postgres/keploy/test-set-0/tests/test-8.yaml b/hono-prisma-postgres/keploy/test-set-0/tests/test-8.yaml new file mode 100755 index 0000000..2f421ef --- /dev/null +++ b/hono-prisma-postgres/keploy/test-set-0/tests/test-8.yaml @@ -0,0 +1,60 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-8 +spec: + metadata: {} + req: + method: PUT + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos?id=cfc860aa-b5b4-4ece-9267-b27b99beb51a + url_params: + id: cfc860aa-b5b4-4ece-9267-b27b99beb51a + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4 + Cache-Control: no-cache + Connection: keep-alive + Content-Length: "39" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 8867398d-a342-44c1-9d56-1146d00c493e + User-Agent: PostmanRuntime/7.43.0 + body: |- + { + "title" : "Test Todo 3 Updated" + } + timestamp: 2024-12-25T16:18:40.246514794+05:30 + resp: + status_code: 200 + header: + Access-Control-Allow-Origin: '*' + Content-Length: "219" + Content-Type: application/json + Date: Wed, 25 Dec 2024 10:48:39 GMT + body: '{"id":"cfc860aa-b5b4-4ece-9267-b27b99beb51a","title":"Test Todo 3 Updated","completed":false,"userId":"8782ef62-7ff8-4671-b1c1-80f30094ee2e","createdAt":"2024-12-25T10:47:47.386Z","updatedAt":"2024-12-25T10:48:40.249Z"}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-12-25T16:18:42.319378031+05:30 + objects: [] + assertions: + noise: + body.createdAt: [] + body.updatedAt: [] + header.Date: [] + created: 1735123722 +curl: |- + curl --request PUT \ + --url http://localhost:3000/todos?id=cfc860aa-b5b4-4ece-9267-b27b99beb51a \ + --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4' \ + --header 'Host: localhost:3000' \ + --header 'Content-Type: application/json' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Connection: keep-alive' \ + --header 'Postman-Token: 8867398d-a342-44c1-9d56-1146d00c493e' \ + --header 'Cache-Control: no-cache' \ + --header 'Accept: */*' \ + --header 'User-Agent: PostmanRuntime/7.43.0' \ + --data "{\n \"title\" : \"Test Todo 3 Updated\"\n}" diff --git a/hono-prisma-postgres/keploy/test-set-0/tests/test-9.yaml b/hono-prisma-postgres/keploy/test-set-0/tests/test-9.yaml new file mode 100755 index 0000000..eeb23b3 --- /dev/null +++ b/hono-prisma-postgres/keploy/test-set-0/tests/test-9.yaml @@ -0,0 +1,51 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-9 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4 + Cache-Control: no-cache + Connection: keep-alive + Host: localhost:3000 + Postman-Token: 3f64eaae-e6cf-41c5-8fb7-b7dd3a05a77c + User-Agent: PostmanRuntime/7.43.0 + body: "" + timestamp: 2024-12-25T16:18:44.914579575+05:30 + resp: + status_code: 200 + header: + Access-Control-Allow-Origin: '*' + Content-Length: "645" + Content-Type: application/json + Date: Wed, 25 Dec 2024 10:48:44 GMT + body: '[{"id":"5ca8f981-e1c8-4dc9-95ce-af5d34b7b9e3","title":"Test Todo 1","completed":false,"userId":"8782ef62-7ff8-4671-b1c1-80f30094ee2e","createdAt":"2024-12-25T10:47:30.130Z","updatedAt":"2024-12-25T10:47:30.130Z"},{"id":"64fd1980-5258-424c-91b7-1d04a550432d","title":"Test Todo 2","completed":false,"userId":"8782ef62-7ff8-4671-b1c1-80f30094ee2e","createdAt":"2024-12-25T10:47:43.658Z","updatedAt":"2024-12-25T10:47:43.658Z"},{"id":"cfc860aa-b5b4-4ece-9267-b27b99beb51a","title":"Test Todo 3 Updated","completed":false,"userId":"8782ef62-7ff8-4671-b1c1-80f30094ee2e","createdAt":"2024-12-25T10:47:47.386Z","updatedAt":"2024-12-25T10:48:40.249Z"}]' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-12-25T16:18:46.93088299+05:30 + objects: [] + assertions: + noise: + body.createdAt: [] + body.updatedAt: [] + header.Date: [] + created: 1735123726 +curl: | + curl --request GET \ + --url http://localhost:3000/todos \ + --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NzgyZWY2Mi03ZmY4LTQ2NzEtYjFjMS04MGYzMDA5NGVlMmUiLCJpYXQiOjE3MzUxMjM2MDR9.xua1on3OilfNQ8Ta3h6EqtL6ce_WmBG5ef_gTwKIyP4' \ + --header 'User-Agent: PostmanRuntime/7.43.0' \ + --header 'Accept: */*' \ + --header 'Cache-Control: no-cache' \ + --header 'Postman-Token: 3f64eaae-e6cf-41c5-8fb7-b7dd3a05a77c' \ + --header 'Host: localhost:3000' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Connection: keep-alive' \ diff --git a/hono-prisma-postgres/package.json b/hono-prisma-postgres/package.json new file mode 100644 index 0000000..61ef7be --- /dev/null +++ b/hono-prisma-postgres/package.json @@ -0,0 +1,28 @@ +{ + "name": "ts-hono-postgres", + "scripts": { + "dev": "bun run --hot src/index.ts", + "build": "bun build src/index.ts" + }, + "dependencies": { + "@prisma/client": "^6.1.0", + "@types/bcrypt": "^5.0.2", + "@types/jsonwebtoken": "^9.0.7", + "@types/pg": "^8.11.10", + "bcrypt": "^5.1.1", + "hono": "^4.6.14", + "jsonwebtoken": "^9.0.2", + "pg": "^8.13.1" + }, + "devDependencies": { + "@types/bun": "latest", + "@types/node": "^22.10.2", + "prisma": "^6.1.0", + "tsx": "^4.19.2" + }, + "module": "index.ts", + "type": "module", + "peerDependencies": { + "typescript": "^5.7.2" + } +} \ No newline at end of file diff --git a/hono-prisma-postgres/prisma/migrations/20241224191132_init/migration.sql b/hono-prisma-postgres/prisma/migrations/20241224191132_init/migration.sql new file mode 100644 index 0000000..05c0826 --- /dev/null +++ b/hono-prisma-postgres/prisma/migrations/20241224191132_init/migration.sql @@ -0,0 +1,28 @@ +-- CreateTable +CREATE TABLE "User" ( + "id" TEXT NOT NULL, + "email" TEXT NOT NULL, + "password" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "User_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Todo" ( + "id" TEXT NOT NULL, + "title" TEXT NOT NULL, + "completed" BOOLEAN NOT NULL DEFAULT false, + "userId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Todo_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); + +-- AddForeignKey +ALTER TABLE "Todo" ADD CONSTRAINT "Todo_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/hono-prisma-postgres/prisma/migrations/migration_lock.toml b/hono-prisma-postgres/prisma/migrations/migration_lock.toml new file mode 100644 index 0000000..648c57f --- /dev/null +++ b/hono-prisma-postgres/prisma/migrations/migration_lock.toml @@ -0,0 +1,3 @@ +# Please do not edit this file manually +# It should be added in your version-control system (e.g., Git) +provider = "postgresql" \ No newline at end of file diff --git a/hono-prisma-postgres/prisma/schema.prisma b/hono-prisma-postgres/prisma/schema.prisma new file mode 100644 index 0000000..282b1df --- /dev/null +++ b/hono-prisma-postgres/prisma/schema.prisma @@ -0,0 +1,33 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? +// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init + +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} + +model User { + id String @id @default(uuid()) + email String @unique + password String + todos Todo[] + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} + +model Todo { + id String @id @default(uuid()) + title String + completed Boolean @default(false) + userId String + user User @relation(fields: [userId], references: [id]) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} \ No newline at end of file diff --git a/hono-prisma-postgres/src/handlers/todoHandler.ts b/hono-prisma-postgres/src/handlers/todoHandler.ts new file mode 100644 index 0000000..8b78c60 --- /dev/null +++ b/hono-prisma-postgres/src/handlers/todoHandler.ts @@ -0,0 +1,152 @@ +import { Context } from "hono"; +import { PrismaClient } from "@prisma/client"; +import { sign, verify } from "jsonwebtoken"; +import { compare, hash } from "bcrypt"; + +const prisma = new PrismaClient(); +const JWT_SECRET = process.env.JWT_SECRET || "your-secret-key"; + +// Auth middleware +export const authMiddleware = async (c: Context, next: Function) => { + const token = c.req.header("Authorization")?.split(" ")[1]; + + if (!token) { + return c.json({ error: "Unauthorized" }, 401); + } + + try { + const decoded = verify(token, JWT_SECRET) as { userId: string }; + c.set("userId", decoded.userId); + await next(); + } catch (error) { + return c.json({ error: "Invalid token" }, 401); + } +}; + +// Auth handlers +export const register = async (c: Context) => { + try { + const { email, password } = await c.req.json(); + + const existingUser = await prisma.user.findUnique({ + where: { email }, + }); + + if (existingUser) { + return c.json({ error: "Email already exists" }, 400); + } + + const hashedPassword = await hash(password, 10); + const user = await prisma.user.create({ + data: { + email, + password: hashedPassword, + }, + }); + + const token = sign({ userId: user.id }, JWT_SECRET); + return c.json({ token }); + } catch (error) { + return c.json({ error: "Registration failed" }, 500); + } +}; + +export const login = async (c: Context) => { + try { + const { email, password } = await c.req.json(); + + const user = await prisma.user.findUnique({ + where: { email }, + }); + + if (!user) { + return c.json({ error: "User not found" }, 404); + } + + const isValid = await compare(password, user.password); + if (!isValid) { + return c.json({ error: "Invalid password" }, 401); + } + + const token = sign({ userId: user.id }, JWT_SECRET); + return c.json({ token }); + } catch (error) { + return c.json({ error: "Login failed" }, 500); + } +}; + +// Todo handlers +export const testResponse = async (c: Context) => { + return c.json({ message: "Hello, world!" }); +}; + +export const createTodo = async (c: Context) => { + try { + const userId = c.get("userId"); + const { title } = await c.req.json(); + + const todo = await prisma.todo.create({ + data: { + title, + userId, + }, + }); + + return c.json(todo); + } catch (error) { + return c.json({ error: "Failed to create todo" }, 500); + } +}; + +export const getTodos = async (c: Context) => { + try { + const userId = c.get("userId"); + const todos = await prisma.todo.findMany({ + where: { userId }, + }); + return c.json(todos); + } catch (error) { + return c.json({ error: "Failed to fetch todos" }, 500); + } +}; + +export const updateTodo = async (c: Context) => { + try { + const userId = c.get("userId"); + const todoId = c.req.query("id"); + const { title, completed } = await c.req.json(); + + const todo = await prisma.todo.update({ + where: { + id: todoId, + userId, + }, + data: { + title, + completed, + }, + }); + + return c.json(todo); + } catch (error) { + return c.json({ error: "Failed to update todo" }, 500); + } +}; + +export const deleteTodo = async (c: Context) => { + try { + const userId = c.get("userId"); + const todoId = c.req.query("id"); + + await prisma.todo.delete({ + where: { + id: todoId, + userId, + }, + }); + + return c.json({ message: "Todo deleted successfully" }); + } catch (error) { + return c.json({ error: "Failed to delete todo" }, 500); + } +}; diff --git a/hono-prisma-postgres/src/index.ts b/hono-prisma-postgres/src/index.ts new file mode 100644 index 0000000..90314d9 --- /dev/null +++ b/hono-prisma-postgres/src/index.ts @@ -0,0 +1,30 @@ +import { Hono } from "hono"; +import { cors } from "hono/cors"; +import { + register, + login, + authMiddleware, + createTodo, + getTodos, + updateTodo, + deleteTodo, + testResponse, +} from "./handlers/todoHandler"; + +const app = new Hono(); + +// Middleware +app.use("/*", cors()); + +// Auth routes +app.get("/", testResponse); +app.post("/register", register); +app.post("/login", login); + +// Protected todo routes +app.post("/todos", authMiddleware, createTodo); +app.get("/todos", authMiddleware, getTodos); +app.put("/todos", authMiddleware, updateTodo); +app.delete("/todos", authMiddleware, deleteTodo); + +export default app; diff --git a/hono-prisma-postgres/tsconfig.json b/hono-prisma-postgres/tsconfig.json new file mode 100644 index 0000000..c442b33 --- /dev/null +++ b/hono-prisma-postgres/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "strict": true, + "jsx": "react-jsx", + "jsxImportSource": "hono/jsx" + } +} \ No newline at end of file