diff --git a/package-lock.json b/package-lock.json index beb3162..435ab56 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "fastify": "^4.26.1", "fastify-plugin": "^4.5.1", "helmet": "^7.1.0", + "json-schema-to-ts": "^3.1.1", "pino": "^8.18.0", "zod": "^3.22.4" }, @@ -677,6 +678,17 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/runtime": { + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.0.tgz", + "integrity": "sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==", + "dependencies": { + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/template": { "version": "7.23.9", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.23.9.tgz", @@ -6075,6 +6087,18 @@ "url": "https://github.com/Eomm/json-schema-resolver?sponsor=1" } }, + "node_modules/json-schema-to-ts": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/json-schema-to-ts/-/json-schema-to-ts-3.1.1.tgz", + "integrity": "sha512-+DWg8jCJG2TEnpy7kOm/7/AxaYoaRbjVB4LFZLySZlWn8exGs3A4OLJR966cVvU26N7X9TWxl+Jsw7dzAqKT6g==", + "dependencies": { + "@babel/runtime": "^7.18.3", + "ts-algebra": "^2.0.0" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -7763,6 +7787,11 @@ "node": ">=8" } }, + "node_modules/regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -8535,6 +8564,11 @@ "node": ">=8" } }, + "node_modules/ts-algebra": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ts-algebra/-/ts-algebra-2.0.0.tgz", + "integrity": "sha512-FPAhNPFMrkwz76P7cdjdmiShwMynZYN6SgOujD1urY4oNm80Ou9oMdmbR45LotcKOXoy7wSmHkRFE6Mxbrhefw==" + }, "node_modules/ts-jest": { "version": "29.1.2", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.2.tgz", diff --git a/package.json b/package.json index b16ec0a..bc36860 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "fastify": "^4.26.1", "fastify-plugin": "^4.5.1", "helmet": "^7.1.0", + "json-schema-to-ts": "^3.1.1", "pino": "^8.18.0", "zod": "^3.22.4" }, diff --git a/src/application/common/interfaces/index.ts b/src/application/common/interfaces/index.ts index b9caf78..377c40d 100644 --- a/src/application/common/interfaces/index.ts +++ b/src/application/common/interfaces/index.ts @@ -1,6 +1,5 @@ export * from './config'; export * from './logger'; -export * from './posts-repository'; export * from './pages-repository'; export * from './sections-repository'; export * from './components-repository'; diff --git a/src/application/common/interfaces/posts-repository.ts b/src/application/common/interfaces/posts-repository.ts deleted file mode 100644 index a2443ee..0000000 --- a/src/application/common/interfaces/posts-repository.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Post } from '@domain/entities'; - -export interface PostsRepository { - create(parameters: { post: Post }): Promise<{ id: string }>; - delete(parameters: { id: string }): Promise; - getById(parameters: { id: string }): Promise; - list(parameters: { pageNumber: number; pageSize: number }): Promise<{ count: number; posts: Array }>; -} diff --git a/src/domain/entities/index.ts b/src/domain/entities/index.ts index 84a0cac..b798280 100644 --- a/src/domain/entities/index.ts +++ b/src/domain/entities/index.ts @@ -1,4 +1,3 @@ -export * from './post'; export * from './page'; export * from './section'; export * from './component'; diff --git a/src/infrastructure/repositories/index.ts b/src/infrastructure/repositories/index.ts index 0f370fb..ab60f99 100644 --- a/src/infrastructure/repositories/index.ts +++ b/src/infrastructure/repositories/index.ts @@ -1,4 +1,3 @@ -export * from './posts-repository'; export * from './pages-repository'; export * from './sections-repository'; export * from './components-repository'; diff --git a/tests/api/client.ts b/tests/api/client.ts index 27de56e..2536d61 100644 --- a/tests/api/client.ts +++ b/tests/api/client.ts @@ -1,4 +1,3 @@ -import { Post } from '@domain/entities'; import { Dependencies } from '@infrastructure/di'; import app from '@web/app'; import { randomUUID } from 'crypto'; @@ -21,33 +20,33 @@ export async function makeClient() { } async function seedDatabase({ db }: Dependencies) { - const posts: Post[] = [ - { - id: randomUUID(), - createdAt: new Date('2024-01-01T00:00:00Z'), - title: 'First post', - }, - { - id: randomUUID(), - createdAt: new Date('2024-01-02T04:24:00Z'), - title: 'Second post', - }, - { - id: randomUUID(), - createdAt: new Date('2024-01-03T00:00:00Z'), - title: 'Third post', - }, - ]; - - await db.post.createMany({ - data: posts.map((post) => ({ - id: post.id, - createdAt: post.createdAt, - title: post.title, - })), - }); - - return { - posts, - }; + // const posts: Post[] = [ + // { + // id: randomUUID(), + // createdAt: new Date('2024-01-01T00:00:00Z'), + // title: 'First post', + // }, + // { + // id: randomUUID(), + // createdAt: new Date('2024-01-02T04:24:00Z'), + // title: 'Second post', + // }, + // { + // id: randomUUID(), + // createdAt: new Date('2024-01-03T00:00:00Z'), + // title: 'Third post', + // }, + // ]; + + // await db.post.createMany({ + // data: posts.map((post) => ({ + // id: post.id, + // createdAt: post.createdAt, + // title: post.title, + // })), + // }); + + // return { + // posts, + // }; }