Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix on with-docker #7915

Merged
merged 14 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions examples/with-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ npx create-turbo@latest -e with-docker

## What's inside?

This turborepo uses [Yarn](https://classic.yarnpkg.com/lang/en/) as a package manager. It includes the following packages/apps:
This Turborepo includes the following:

### Apps and Packages

- `@repo/web`: a [Next.js](https://nextjs.org/) app
- `@repo/api`: an [Express](https://expressjs.com/) server
- `@repo/ui`: ui: a React component library
- `@repo/eslint-config-custom`: `eslint` configurations for client side applications (includes `eslint-config-next` and `eslint-config-prettier`)
- `@repo/eslint-config-custom-server`: `eslint` configurations for server side applications (includes `eslint-config-next` and `eslint-config-prettier`)
- `scripts`: Jest configurations
- `web`: a [Next.js](https://nextjs.org/) app
- `api`: an [Express](https://expressjs.com/) server
- `@repo/ui`: a React component library
- `@repo/logger`: Isomorphic logger (a small wrapper around console.log)
- `@repo/eslint-config`: ESLint presets
- `@repo/typescript-config`: tsconfig.json's used throughout the monorepo
- `@repo/jest-presets`: Jest configurations

Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).

Expand Down
4 changes: 2 additions & 2 deletions examples/with-docker/apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"test": "jest --detectOpenHandles"
},
"jest": {
"preset": "@repo/jest-presets/jest/node"
"preset": "@repo/jest-presets/node"
},
"dependencies": {
"@repo/logger": "*",
Expand Down Expand Up @@ -39,4 +39,4 @@
"supertest": "^6.3.3",
"typescript": "^5.3.3"
}
}
}
6 changes: 3 additions & 3 deletions examples/with-docker/apps/api/src/__tests__/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import supertest from "supertest";
import { createServer } from "../server";

describe("server", () => {
it("health check returns 200", async () => {
it("status check returns 200", async () => {
await supertest(createServer())
.get("/healthz")
.get("/status")
.expect(200)
.then((res) => {
expect(res.body.ok).toBe(true);
Expand All @@ -16,7 +16,7 @@ describe("server", () => {
.get("/message/jared")
.expect(200)
.then((res) => {
expect(res.body).toEqual({ message: "hello jared" });
expect(res.body.message).toBe("hello jared");
});
});
});
4 changes: 0 additions & 4 deletions examples/with-docker/apps/api/src/__tests__/tsconfig.json

This file was deleted.

6 changes: 3 additions & 3 deletions examples/with-docker/apps/api/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { json, urlencoded } from "body-parser";
import express from "express";
import express, { type Express } from "express";
import morgan from "morgan";
import cors from "cors";

export const createServer = () => {
export const createServer = (): Express => {
const app = express();
app
.disable("x-powered-by")
Expand All @@ -14,7 +14,7 @@ export const createServer = () => {
.get("/message/:name", (req, res) => {
return res.json({ message: `hello ${req.params.name}` });
})
.get("/healthz", (req, res) => {
.get("/status", (_, res) => {
return res.json({ ok: true });
});

Expand Down
6 changes: 3 additions & 3 deletions examples/with-docker/apps/web/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { useEffect, useState, ChangeEvent, FormEvent } from "react";
import { Button } from "@repo/ui/button";
import { useEffect, useState } from "react";

const API_HOST = process.env.NEXT_PUBLIC_API_HOST || "http://localhost:3001";

Expand All @@ -15,10 +15,10 @@ export default function Web() {
setError(undefined);
}, [name]);

const onChange = (e: React.ChangeEvent<HTMLInputElement>) =>
const onChange = (e: ChangeEvent<HTMLInputElement>) =>
setName(e.target.value);

const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
const onSubmit = async (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();

try {
Expand Down
5 changes: 4 additions & 1 deletion examples/with-docker/packages/jest-presets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"version": "0.0.0",
"private": true,
"license": "MIT",
"files": [
"node/jest-preset.js"
],
"dependencies": {
"ts-jest": "^29.1.1"
}
}
}
11 changes: 6 additions & 5 deletions examples/with-docker/packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
"test": "jest"
},
"jest": {
"preset": "@repo/jest-presets/jest/node"
"preset": "@repo/jest-presets/node"
},
"devDependencies": {
"@repo/eslint-config": "workspace:*",
"@repo/jest-presets": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.24",
"eslint": "^8.57.0",
"@repo/eslint-config": "*",
"jest": "^29.7.0",
"@repo/jest-presets": "*",
"@repo/typescript-config": "*",
"typescript": "^5.3.3"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ jest.spyOn(global.console, "log");
describe("@repo/logger", () => {
it("prints a message", () => {
log("hello");
expect(console.log).toBeCalled();
expect(console.log).toHaveBeenCalled();
});
});

This file was deleted.

5 changes: 3 additions & 2 deletions examples/with-docker/packages/logger/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"extends": "@repo/typescript-config/base.json",
"compilerOptions": {
"lib": ["ES2015"],
"lib": ["ES2015", "DOM"],
"outDir": "./dist",
"rootDir": "./src"
"rootDir": "./src",
"types": ["jest", "node"]
},
"include": ["src"],
"exclude": ["node_modules"]
Expand Down