diff --git a/.changeset/beige-experts-occur.md b/.changeset/beige-experts-occur.md new file mode 100644 index 00000000..67d43312 --- /dev/null +++ b/.changeset/beige-experts-occur.md @@ -0,0 +1,5 @@ +--- +'@snipcode/backend': patch +--- + +Build the backend API homepage diff --git a/.github/actions/install-dependencies/action.yml b/.github/actions/install-dependencies/action.yml index b8183e02..59984267 100644 --- a/.github/actions/install-dependencies/action.yml +++ b/.github/actions/install-dependencies/action.yml @@ -24,7 +24,7 @@ runs: shell: bash run: | corepack enable - yarn set version 4.3.1 + yarn set version 4.4.0 - name: Install projects dependencies shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3d5a1fb0..9a9b19c0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,7 +68,7 @@ jobs: - name: Install Yarn 4 run: | corepack enable - yarn set version 4.3.1 + yarn set version 4.4.0 - name: Install Vercel CLI run: npm install --global vercel@latest diff --git a/.github/workflows/deploy-frontend.yml b/.github/workflows/deploy-frontend.yml index 8c49e4ef..0ca41291 100644 --- a/.github/workflows/deploy-frontend.yml +++ b/.github/workflows/deploy-frontend.yml @@ -23,7 +23,7 @@ jobs: - name: Install Yarn 4 run: | corepack enable - yarn set version 4.3.1 + yarn set version 4.4.0 - name: Install Vercel CLI run: npm install --global vercel@latest diff --git a/apps/backend/Dockerfile b/apps/backend/Dockerfile index ae4152ab..70bdfd94 100644 --- a/apps/backend/Dockerfile +++ b/apps/backend/Dockerfile @@ -6,7 +6,7 @@ WORKDIR /app COPY . . -RUN corepack enable && yarn set version berry +RUN corepack enable && yarn set version 4.4.0 RUN yarn install @@ -35,7 +35,7 @@ ENV APP_VERSION=${APP_VERSION} WORKDIR /app -RUN corepack enable && yarn set version berry +RUN corepack enable && yarn set version 4.4.0 COPY --chown=node:node --from=builder /app/package.json . COPY --chown=node:node --from=builder /app/.yarnrc.yml . @@ -43,12 +43,6 @@ COPY --chown=node:node --from=builder /app/.yarnrc.yml . COPY --chown=node:node --from=builder /app/apps/backend/dist/src ./apps/backend/src COPY --chown=node:node --from=builder /app/apps/backend/package.json ./apps/backend -COPY --chown=node:node --from=builder /app/apps/backend/src/features/schema.graphql ./apps/backend/src/features/schema.graphql -COPY --chown=node:node --from=builder /app/apps/backend/src/features/users/graphql/schema.graphql ./apps/backend/src/features/users/graphql/schema.graphql -COPY --chown=node:node --from=builder /app/apps/backend/src/features/snippets/graphql/schema.graphql ./apps/backend/src/features/snippets/graphql/schema.graphql -COPY --chown=node:node --from=builder /app/apps/backend/src/features/folders/graphql/schema.graphql ./apps/backend/src/features/folders/graphql/schema.graphql -COPY --chown=node:node --from=builder /app/apps/backend/src/features/auth/graphql/schema.graphql ./apps/backend/src/features/auth/graphql/schema.graphql - COPY --chown=node:node --from=builder /app/packages/domain/package.json ./packages/domain/package.json COPY --chown=node:node --from=builder /app/packages/domain/dist ./packages/domain/dist diff --git a/apps/backend/jest.config.ts b/apps/backend/jest.config.ts index b48aaa30..281ec792 100644 --- a/apps/backend/jest.config.ts +++ b/apps/backend/jest.config.ts @@ -5,7 +5,7 @@ const config: Config.InitialOptions = { maxWorkers: 1, moduleFileExtensions: ['js', 'json', 'ts'], preset: 'ts-jest', - roots: ['.'], + roots: ['src'], snapshotFormat: { printBasicPrototype: false, }, diff --git a/apps/backend/nest-cli.json b/apps/backend/nest-cli.json index f9aa683b..5fbe064d 100644 --- a/apps/backend/nest-cli.json +++ b/apps/backend/nest-cli.json @@ -3,6 +3,14 @@ "collection": "@nestjs/schematics", "sourceRoot": "src", "compilerOptions": { - "deleteOutDir": true + "deleteOutDir": true, + "assets": [ + { "include": "assets", "outDir": "dist/src", "watchAssets": true }, + { "include": "features/schema.graphql", "outDir": "dist/src", "watchAssets": true }, + { "include": "features/auth/graphql/schema.graphql", "outDir": "dist/src", "watchAssets": true }, + { "include": "features/folders/graphql/schema.graphql", "outDir": "dist/src", "watchAssets": true }, + { "include": "features/snippets/graphql/schema.graphql", "outDir": "dist/src", "watchAssets": true }, + { "include": "features/users/graphql/schema.graphql", "outDir": "dist/src", "watchAssets": true } + ] } } diff --git a/apps/backend/package.json b/apps/backend/package.json index fbc74742..ca2a93a3 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -8,8 +8,8 @@ "scripts": { "build": "nest build", "clean": "rm -rf .turbo dist build logs", - "dev": "dotenv -e .env.local -- nest start --watch", - "dev:debug": "nest start --debug --watch", + "dev": "dotenv -e .env.local -- nest start --watch --watchAssets", + "dev:debug": "dotenv -e .env.local -- nest start --debug --watch", "gql:gen:types": "ts-node scripts/generate-graphql-types.ts", "lint": "eslint \"{src,scripts}/**/*.ts\" --fix", "prod": "node dist/main", @@ -27,6 +27,7 @@ "@nestjs/core": "10.3.9", "@nestjs/graphql": "12.1.1", "@nestjs/platform-express": "10.3.9", + "@nestjs/serve-static": "4.0.2", "@prisma/client": "5.14.0", "@sentry/node": "8.11.0", "@snipcode/domain": "workspace:*", diff --git a/apps/backend/src/app.module.ts b/apps/backend/src/app.module.ts index fe837dce..76524cc5 100644 --- a/apps/backend/src/app.module.ts +++ b/apps/backend/src/app.module.ts @@ -1,13 +1,15 @@ +import { join } from 'path'; + import { ApolloServerPlugin } from '@apollo/server'; import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default'; import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo'; import { Logger, Module } from '@nestjs/common'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { GraphQLModule } from '@nestjs/graphql'; +import { ServeStaticModule } from '@nestjs/serve-static'; import { DomainModule } from '@snipcode/domain'; import { EnvironmentVariables, validate } from './configs/environment'; -import { AppController } from './features/app/app.controller'; import { AppService } from './features/app/app.service'; import { AuthFeatureModule } from './features/auth/auth.module'; import { FolderFeatureModule } from './features/folders/folder.module'; @@ -19,7 +21,7 @@ import { DateScalar } from './utils/graphql/date-scalar'; const explorerPlugin: ApolloServerPlugin[] = IS_DEV ? [ApolloServerPluginLandingPageLocalDefault({ embed: true })] : []; @Module({ - controllers: [AppController], + controllers: [], imports: [ ConfigModule.forRoot({ envFilePath: ['.env.local', '.env.test'], @@ -54,6 +56,12 @@ const explorerPlugin: ApolloServerPlugin[] = IS_DEV ? [ApolloServerPluginLanding }; }, }), + ServeStaticModule.forRoot({ + exclude: ['/graphql', '/auth*', '/snippets*'], + renderPath: '/', + rootPath: join(__dirname, 'assets'), + serveRoot: '/', + }), AuthFeatureModule, FolderFeatureModule, SnippetFeatureModule, diff --git a/apps/backend/src/assets/favicon.ico b/apps/backend/src/assets/favicon.ico new file mode 100644 index 00000000..2c6859a3 Binary files /dev/null and b/apps/backend/src/assets/favicon.ico differ diff --git a/apps/backend/src/assets/index.html b/apps/backend/src/assets/index.html new file mode 100644 index 00000000..a48727c9 --- /dev/null +++ b/apps/backend/src/assets/index.html @@ -0,0 +1,65 @@ + + +
+ + + + +