feat(create-turbo): apply official-starter transform

This commit is contained in:
Turbobot
2025-02-08 13:41:40 -08:00
committed by ryan
parent 9fe2818df8
commit c158dda08f
48 changed files with 5621 additions and 24 deletions
@@ -0,0 +1,23 @@
import supertest from "supertest";
import { describe, it, expect } from "@jest/globals";
import { createServer } from "../server";
describe("server", () => {
it("status check returns 200", async () => {
await supertest(createServer())
.get("/status")
.expect(200)
.then((res) => {
expect(res.body.ok).toBe(true);
});
});
it("message endpoint says hello", async () => {
await supertest(createServer())
.get("/message/jared")
.expect(200)
.then((res) => {
expect(res.body.message).toBe("hello jared");
});
});
});
+9
View File
@@ -0,0 +1,9 @@
import { createServer } from "./server";
import { log } from "@repo/logger";
const port = process.env.PORT || 3001;
const server = createServer();
server.listen(port, () => {
log(`api running on ${port}`);
});
+22
View File
@@ -0,0 +1,22 @@
import { json, urlencoded } from "body-parser";
import express, { type Express } from "express";
import morgan from "morgan";
import cors from "cors";
export const createServer = (): Express => {
const app = express();
app
.disable("x-powered-by")
.use(morgan("dev"))
.use(urlencoded({ extended: true }))
.use(json())
.use(cors())
.get("/message/:name", (req, res) => {
return res.json({ message: `hello ${req.params.name}` });
})
.get("/status", (_, res) => {
return res.json({ ok: true });
});
return app;
};