chore: rename to template
This commit is contained in:
parent
063dfe39e9
commit
c011186c37
46 changed files with 143 additions and 142 deletions
4
apps/express-template/eslint.config.js
Normal file
4
apps/express-template/eslint.config.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import { config } from "@repo/eslint-config";
|
||||
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
export default config;
|
||||
41
apps/express-template/package.json
Normal file
41
apps/express-template/package.json
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"name": "express-template",
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node dist/index.js",
|
||||
"dev": "tsup --watch --onSuccess \"node dist/index.cjs\"",
|
||||
"build": "tsup",
|
||||
"check-types": "tsc --noEmit",
|
||||
"lint": "eslint src/ --max-warnings 0",
|
||||
"test": "jest --detectOpenHandles"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "@repo/jest-presets/node"
|
||||
},
|
||||
"dependencies": {
|
||||
"@repo/logger": "*",
|
||||
"body-parser": "^1.20.3",
|
||||
"cors": "^2.8.5",
|
||||
"express": "4.21.2",
|
||||
"morgan": "^1.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jest/globals": "^29.7.0",
|
||||
"@repo/eslint-config": "*",
|
||||
"@repo/jest-presets": "*",
|
||||
"@repo/typescript-config": "*",
|
||||
"@types/body-parser": "^1.19.5",
|
||||
"@types/cors": "^2.8.17",
|
||||
"@types/express": "4.17.21",
|
||||
"@types/morgan": "^1.9.9",
|
||||
"@types/node": "^22.15.3",
|
||||
"@types/supertest": "^6.0.2",
|
||||
"eslint": "^9.29.0",
|
||||
"jest": "^29.7.0",
|
||||
"supertest": "^7.1.0",
|
||||
"tsup": "^8.5.0",
|
||||
"typescript": "5.8.2"
|
||||
}
|
||||
}
|
||||
23
apps/express-template/src/__tests__/server.test.ts
Normal file
23
apps/express-template/src/__tests__/server.test.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import supertest from "supertest";
|
||||
import { describe, it, expect } from "@jest/globals";
|
||||
import { createServer } from "../server";
|
||||
|
||||
describe("Server", () => {
|
||||
it("health check returns 200", async () => {
|
||||
await supertest(createServer())
|
||||
.get("/status")
|
||||
.expect(200)
|
||||
.then((res) => {
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("message endpoint says hello", async () => {
|
||||
await supertest(createServer())
|
||||
.get("/message/jared")
|
||||
.expect(200)
|
||||
.then((res) => {
|
||||
expect(res.body).toEqual({ message: "hello jared" });
|
||||
});
|
||||
});
|
||||
});
|
||||
9
apps/express-template/src/index.ts
Normal file
9
apps/express-template/src/index.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { log } from "@repo/logger";
|
||||
import { createServer } from "./server";
|
||||
|
||||
const port = process.env.PORT || 5001;
|
||||
const server = createServer();
|
||||
|
||||
server.listen(port, () => {
|
||||
log(`api running on ${port}`);
|
||||
});
|
||||
22
apps/express-template/src/server.ts
Normal file
22
apps/express-template/src/server.ts
Normal 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;
|
||||
};
|
||||
9
apps/express-template/tsconfig.json
Normal file
9
apps/express-template/tsconfig.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"extends": "@repo/typescript-config/base.json",
|
||||
"compilerOptions": {
|
||||
"lib": ["ES2015"],
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"exclude": ["node_modules"],
|
||||
"include": ["."]
|
||||
}
|
||||
8
apps/express-template/tsup.config.ts
Normal file
8
apps/express-template/tsup.config.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import { defineConfig, type Options } from "tsup";
|
||||
|
||||
export default defineConfig((options: Options) => ({
|
||||
entry: ["src/**/*"],
|
||||
clean: true,
|
||||
format: ["cjs"],
|
||||
...options,
|
||||
}));
|
||||
9
apps/express-template/turbo.json
Normal file
9
apps/express-template/turbo.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"extends": ["//"],
|
||||
"tasks": {
|
||||
"build": {
|
||||
"env": ["PORT"],
|
||||
"outputs": ["dist/**"]
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue