-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): fastify typebox integration (#314)
* refactor(api): add bff types * refactor(api): refactor typebox types * feat(api): add findById integration * refactor(api): remove /workspace * refactor(api): add schema types * feat(api): add name update api * feat(api): add update project api
- Loading branch information
1 parent
c103dea
commit 44cd83c
Showing
38 changed files
with
1,020 additions
and
680 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export namespace ApiTypes { | ||
export { | ||
GetProjectByIdApi, | ||
DeleteProjectApi, | ||
CreateProjectApi, | ||
UpdateProjectNameApi, | ||
UpdateProjectApi, | ||
} from '../src/schemas'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
apps/api/prisma/migrations/20220801191000_project_required_relationship/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `projectId` on the `SnippetEditorOptions` table. All the data in the column will be lost. | ||
- You are about to drop the column `projectId` on the `SnippetFrame` table. All the data in the column will be lost. | ||
- You are about to drop the column `projectId` on the `SnippetTerminal` table. All the data in the column will be lost. | ||
- A unique constraint covering the columns `[frameId]` on the table `Project` will be added. If there are existing duplicate values, this will fail. | ||
- A unique constraint covering the columns `[terminalId]` on the table `Project` will be added. If there are existing duplicate values, this will fail. | ||
- A unique constraint covering the columns `[editorOptionsId]` on the table `Project` will be added. If there are existing duplicate values, this will fail. | ||
- Added the required column `editorOptionsId` to the `Project` table without a default value. This is not possible if the table is not empty. | ||
- Added the required column `frameId` to the `Project` table without a default value. This is not possible if the table is not empty. | ||
- Added the required column `terminalId` to the `Project` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "SnippetEditorOptions" DROP CONSTRAINT "SnippetEditorOptions_projectId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "SnippetFrame" DROP CONSTRAINT "SnippetFrame_projectId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "SnippetTerminal" DROP CONSTRAINT "SnippetTerminal_projectId_fkey"; | ||
|
||
-- DropIndex | ||
DROP INDEX "SnippetEditorOptions_projectId_key"; | ||
|
||
-- DropIndex | ||
DROP INDEX "SnippetFrame_projectId_key"; | ||
|
||
-- DropIndex | ||
DROP INDEX "SnippetTerminal_projectId_key"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Project" ADD COLUMN "editorOptionsId" TEXT NOT NULL, | ||
ADD COLUMN "frameId" TEXT NOT NULL, | ||
ADD COLUMN "terminalId" TEXT NOT NULL; | ||
|
||
-- AlterTable | ||
ALTER TABLE "SnippetEditorOptions" DROP COLUMN "projectId"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "SnippetFrame" DROP COLUMN "projectId"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "SnippetTerminal" DROP COLUMN "projectId"; | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Project_frameId_key" ON "Project"("frameId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Project_terminalId_key" ON "Project"("terminalId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Project_editorOptionsId_key" ON "Project"("editorOptionsId"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Project" ADD CONSTRAINT "Project_frameId_fkey" FOREIGN KEY ("frameId") REFERENCES "SnippetFrame"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Project" ADD CONSTRAINT "Project_terminalId_fkey" FOREIGN KEY ("terminalId") REFERENCES "SnippetTerminal"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Project" ADD CONSTRAINT "Project_editorOptionsId_fkey" FOREIGN KEY ("editorOptionsId") REFERENCES "SnippetEditorOptions"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
11 changes: 11 additions & 0 deletions
11
apps/api/prisma/migrations/20220803210003_project_editors_unique_index/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
Warnings: | ||
- A unique constraint covering the columns `[id,projectId]` on the table `SnippetEditorTab` will be added. If there are existing duplicate values, this will fail. | ||
*/ | ||
-- DropIndex | ||
DROP INDEX "SnippetEditorTab_projectId_key"; | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "SnippetEditorTab_id_projectId_key" ON "SnippetEditorTab"("id", "projectId"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {Static, TSchema} from '@sinclair/typebox'; | ||
import {FastifySchema} from 'fastify'; | ||
|
||
type StaticSchemaOrType<T> = T extends TSchema ? Static<T> : T; | ||
|
||
type GetApiRequest<T extends FastifySchema> = { | ||
body?: StaticSchemaOrType<T['body']>; | ||
querystring?: StaticSchemaOrType<T['querystring']>; | ||
params?: StaticSchemaOrType<T['params']>; | ||
headers?: StaticSchemaOrType<T['headers']>; | ||
}; | ||
|
||
type GetApiResponse<T extends FastifySchema> = T['response'] extends { | ||
200?: infer U; | ||
} | ||
? U extends TSchema | ||
? Static<U> | ||
: U | ||
: never; | ||
|
||
export interface GetApiTypes<T extends FastifySchema> { | ||
request: GetApiRequest<T>; | ||
response: GetApiResponse<T>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './projectCreateRequest'; | ||
export * from './projectDeleteRequest'; | ||
export * from './projectUpdateRequest'; |
23 changes: 23 additions & 0 deletions
23
apps/api/src/modules/project/domain/projectUpdateRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { | ||
Project, | ||
SnippetEditorOptions, | ||
SnippetEditorTab, | ||
SnippetFrame, | ||
SnippetTerminal, | ||
} from '@codeimage/prisma-models/*'; | ||
|
||
type IdAndProjectId = 'id' | 'projectId'; | ||
|
||
export interface ProjectUpdateRequest { | ||
editorOptions: Omit<SnippetEditorOptions, IdAndProjectId>; | ||
terminal: Omit<SnippetTerminal, IdAndProjectId>; | ||
frame: Omit<SnippetFrame, IdAndProjectId>; | ||
editors: SnippetEditorTab[]; | ||
} | ||
|
||
export type ProjectUpdateResponse = Project & { | ||
editorOptions: SnippetEditorOptions | null; | ||
terminal: SnippetTerminal | null; | ||
frame: SnippetFrame | null; | ||
editorTabs: SnippetEditorTab[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.