Phase0
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -6,13 +6,15 @@
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"typecheck": "tsc --noEmit"
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"zod": "^3.24.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@hexahost/typescript-config": "workspace:*",
|
||||
"typescript": "^5.7.3"
|
||||
"typescript": "^5.7.3",
|
||||
"vitest": "^3.0.8"
|
||||
}
|
||||
}
|
||||
|
||||
16
packages/contracts/src/error.test.ts
Normal file
16
packages/contracts/src/error.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { problemDetailsSchema } from "./error";
|
||||
|
||||
describe("problemDetailsSchema", () => {
|
||||
it("accepts RFC 7807 problem details", () => {
|
||||
const result = problemDetailsSchema.safeParse({
|
||||
type: "https://example.com/errors/validation",
|
||||
title: "Validation failed",
|
||||
status: 400,
|
||||
detail: "Invalid input",
|
||||
instance: "/api/v1/servers",
|
||||
});
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
});
|
||||
23
packages/contracts/src/health.test.ts
Normal file
23
packages/contracts/src/health.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { healthResponseSchema } from "./health";
|
||||
|
||||
describe("healthResponseSchema", () => {
|
||||
it("accepts a valid liveness response", () => {
|
||||
const result = healthResponseSchema.safeParse({
|
||||
status: "ok",
|
||||
service: "api",
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects invalid status values", () => {
|
||||
const result = healthResponseSchema.safeParse({
|
||||
status: "unknown",
|
||||
service: "api",
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -5,5 +5,5 @@
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
"exclude": ["node_modules", "dist", "src/**/*.test.ts"]
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
17
packages/contracts/vitest.config.ts
Normal file
17
packages/contracts/vitest.config.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { defineConfig } from "vitest/config";
|
||||
|
||||
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: "node",
|
||||
include: ["src/**/*.test.ts"],
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(dirname, "./src"),
|
||||
},
|
||||
},
|
||||
});
|
||||
25
packages/eslint-config/base.js
Normal file
25
packages/eslint-config/base.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
es2022: true,
|
||||
node: true,
|
||||
},
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
},
|
||||
plugins: ["@typescript-eslint"],
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
],
|
||||
ignorePatterns: ["dist", "node_modules", ".next", ".turbo"],
|
||||
rules: {
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
|
||||
],
|
||||
},
|
||||
};
|
||||
8
packages/eslint-config/package.json
Normal file
8
packages/eslint-config/package.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "@hexahost/eslint-config",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"exports": {
|
||||
"./base": "./base.js"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user