From 115ee64be37b57d2dc99d793b0102a8b247ad100 Mon Sep 17 00:00:00 2001 From: mpppk Date: Tue, 24 Sep 2024 10:22:21 +0900 Subject: [PATCH] common to core --- examples/express/valibot/express.ts | 2 +- examples/express/valibot/fetch.ts | 4 ++-- examples/express/zod/express.ts | 2 +- examples/express/zod/fetch.ts | 4 ++-- examples/fastify/zod/fetch.ts | 2 +- package.json | 8 ++++---- src/{common => core}/hono-types.ts | 0 src/{common => core}/index.ts | 0 src/{common => core}/query-string.ts | 0 src/{common => core}/spec.test.ts | 0 src/{common => core}/spec.ts | 0 src/{common => core}/type-test.ts | 0 src/{common => core}/type.t-test.ts | 0 src/{common => core}/type.ts | 0 src/{common => core}/url.t-test.ts | 0 src/{common => core}/url.ts | 0 src/{common => core}/validate.test.ts | 0 src/{common => core}/validate.ts | 0 src/express/index.ts | 4 ++-- src/express/valibot.test.ts | 2 +- src/express/valibot.ts | 2 +- src/express/zod.test.ts | 2 +- src/express/zod.ts | 2 +- src/fastify/zod.ts | 2 +- src/fetch/index.t-test.ts | 2 +- src/fetch/index.ts | 4 ++-- src/index.ts | 2 +- src/valibot/index.ts | 4 ++-- src/zod/index.ts | 4 ++-- 29 files changed, 26 insertions(+), 26 deletions(-) rename src/{common => core}/hono-types.ts (100%) rename src/{common => core}/index.ts (100%) rename src/{common => core}/query-string.ts (100%) rename src/{common => core}/spec.test.ts (100%) rename src/{common => core}/spec.ts (100%) rename src/{common => core}/type-test.ts (100%) rename src/{common => core}/type.t-test.ts (100%) rename src/{common => core}/type.ts (100%) rename src/{common => core}/url.t-test.ts (100%) rename src/{common => core}/url.ts (100%) rename src/{common => core}/validate.test.ts (100%) rename src/{common => core}/validate.ts (100%) diff --git a/examples/express/valibot/express.ts b/examples/express/valibot/express.ts index 3382444..376eb86 100644 --- a/examples/express/valibot/express.ts +++ b/examples/express/valibot/express.ts @@ -16,7 +16,7 @@ const newApp = () => { // ``` // // validatorMiddleware allows to use res.locals.validate method // app.use(validatorMiddleware(pathMap)); - // // wApp is same as app, but with additional common information + // // wApp is same as app, but with additional core information // const wApp = app as TRouter; // ``` const wApp = asAsync(typed(pathMap, app)); diff --git a/examples/express/valibot/fetch.ts b/examples/express/valibot/fetch.ts index f7b4996..1464c28 100644 --- a/examples/express/valibot/fetch.ts +++ b/examples/express/valibot/fetch.ts @@ -36,7 +36,7 @@ const main = async () => { } { // query parameter example - // TODO: Add common information for query parameter + // TODO: Add core information for query parameter const path = `${origin}/users?page=1`; const method = "get"; const res = await fetchT(path, { method }); @@ -58,7 +58,7 @@ const main = async () => { method, headers, // body is the request schema defined in pathMap["/users"]["post"].body - // stringify is same as JSON.stringify but with common information + // stringify is same as JSON.stringify but with core information body: JSONT.stringify({ userName: "user1" }), }); if (res.ok) { diff --git a/examples/express/zod/express.ts b/examples/express/zod/express.ts index 6b413a4..dc741bc 100644 --- a/examples/express/zod/express.ts +++ b/examples/express/zod/express.ts @@ -16,7 +16,7 @@ const newApp = () => { // ``` // // validatorMiddleware allows to use res.locals.validate method // app.use(validatorMiddleware(pathMap)); - // // wApp is same as app, but with additional common information + // // wApp is same as app, but with additional core information // const wApp = app as TRouter; // ``` const wApp = asAsync(typed(pathMap, app)); diff --git a/examples/express/zod/fetch.ts b/examples/express/zod/fetch.ts index eaf1dcd..f99c814 100644 --- a/examples/express/zod/fetch.ts +++ b/examples/express/zod/fetch.ts @@ -36,7 +36,7 @@ const main = async () => { } { // query parameter example - // TODO: Add common information for query parameter + // TODO: Add core information for query parameter const path = `${origin}/users?page=1`; const method = "get"; const res = await fetchT(path, { method }); @@ -58,7 +58,7 @@ const main = async () => { method, headers, // body is the request schema defined in pathMap["/users"]["post"].body - // stringify is same as JSON.stringify but with common information + // stringify is same as JSON.stringify but with core information body: JSONT.stringify({ userName: "user1" }), }); if (res.ok) { diff --git a/examples/fastify/zod/fetch.ts b/examples/fastify/zod/fetch.ts index a127e61..0a11079 100644 --- a/examples/fastify/zod/fetch.ts +++ b/examples/fastify/zod/fetch.ts @@ -42,7 +42,7 @@ const main = async () => { method, headers, // body is the request schema defined in pathMap["/users"]["post"].body - // stringify is same as JSON.stringify but with common information + // stringify is same as JSON.stringify but with core information body: JSONT.stringify({ userName: "user1" }), }); if (res.ok) { diff --git a/package.json b/package.json index 3a12e33..76e03c8 100644 --- a/package.json +++ b/package.json @@ -73,10 +73,10 @@ "import": "./dist/index.mjs", "types": "./dist/index.d.ts" }, - "./common": { - "require": "./dist/common/index.js", - "import": "./dist/common/index.mjs", - "types": "./dist/common/index.d.ts" + "./core": { + "require": "./dist/core/index.js", + "import": "./dist/core/index.mjs", + "types": "./dist/core/index.d.ts" }, "./express": { "require": "./dist/express/index.js", diff --git a/src/common/hono-types.ts b/src/core/hono-types.ts similarity index 100% rename from src/common/hono-types.ts rename to src/core/hono-types.ts diff --git a/src/common/index.ts b/src/core/index.ts similarity index 100% rename from src/common/index.ts rename to src/core/index.ts diff --git a/src/common/query-string.ts b/src/core/query-string.ts similarity index 100% rename from src/common/query-string.ts rename to src/core/query-string.ts diff --git a/src/common/spec.test.ts b/src/core/spec.test.ts similarity index 100% rename from src/common/spec.test.ts rename to src/core/spec.test.ts diff --git a/src/common/spec.ts b/src/core/spec.ts similarity index 100% rename from src/common/spec.ts rename to src/core/spec.ts diff --git a/src/common/type-test.ts b/src/core/type-test.ts similarity index 100% rename from src/common/type-test.ts rename to src/core/type-test.ts diff --git a/src/common/type.t-test.ts b/src/core/type.t-test.ts similarity index 100% rename from src/common/type.t-test.ts rename to src/core/type.t-test.ts diff --git a/src/common/type.ts b/src/core/type.ts similarity index 100% rename from src/common/type.ts rename to src/core/type.ts diff --git a/src/common/url.t-test.ts b/src/core/url.t-test.ts similarity index 100% rename from src/common/url.t-test.ts rename to src/core/url.t-test.ts diff --git a/src/common/url.ts b/src/core/url.ts similarity index 100% rename from src/common/url.ts rename to src/core/url.ts diff --git a/src/common/validate.test.ts b/src/core/validate.test.ts similarity index 100% rename from src/common/validate.test.ts rename to src/core/validate.test.ts diff --git a/src/common/validate.ts b/src/core/validate.ts similarity index 100% rename from src/common/validate.ts rename to src/core/validate.ts diff --git a/src/express/index.ts b/src/express/index.ts index 8bc4fab..8a6f375 100644 --- a/src/express/index.ts +++ b/src/express/index.ts @@ -13,13 +13,13 @@ import { Request, Response, } from "express-serve-static-core"; -import { StatusCode } from "../common"; +import { StatusCode } from "../core"; import { ParsedQs } from "qs"; import { AnyValidators, ValidatorsInput, ValidatorsMap, -} from "../common/validate"; +} from "../core/validate"; /** * Express Request Handler, but with more strict type information. diff --git a/src/express/valibot.test.ts b/src/express/valibot.test.ts index c4a2f65..60bc148 100644 --- a/src/express/valibot.test.ts +++ b/src/express/valibot.test.ts @@ -4,7 +4,7 @@ import express from "express"; import { asAsync, ValidateLocals, validatorMiddleware } from "./index"; import * as v from "valibot"; import { Request } from "express"; -import { ParseUrlParams } from "../common"; +import { ParseUrlParams } from "../core"; import { ToHandlers, typed } from "./valibot"; import { newValibotValidator, diff --git a/src/express/valibot.ts b/src/express/valibot.ts index b593228..1e3ccea 100644 --- a/src/express/valibot.ts +++ b/src/express/valibot.ts @@ -5,7 +5,7 @@ import { ValibotApiSpec, ValibotValidators, } from "../valibot"; -import { Method } from "../common"; +import { Method } from "../core"; import { RouterT, ToHandler as ToPureHandler, diff --git a/src/express/zod.test.ts b/src/express/zod.test.ts index ea07c27..02210bd 100644 --- a/src/express/zod.test.ts +++ b/src/express/zod.test.ts @@ -10,7 +10,7 @@ import { } from "../zod"; import { z, ZodError } from "zod"; import { Request } from "express"; -import { ParseUrlParams } from "../common"; +import { ParseUrlParams } from "../core"; import { ToHandlers, typed } from "./zod"; type ZodValidateLocals< diff --git a/src/express/zod.ts b/src/express/zod.ts index 988146b..669a46a 100644 --- a/src/express/zod.ts +++ b/src/express/zod.ts @@ -5,7 +5,7 @@ import { ZodApiSpec, ZodValidators, } from "../zod"; -import { Method } from "../common"; +import { Method } from "../core"; import { RouterT, ToHandler as ToPureHandler, diff --git a/src/fastify/zod.ts b/src/fastify/zod.ts index 5c5b6ef..05cc4d3 100644 --- a/src/fastify/zod.ts +++ b/src/fastify/zod.ts @@ -1,5 +1,5 @@ import { ZodApiEndpoint, ZodApiEndpoints, ZodApiSpec } from "../zod"; -import { AnyApiResponses, Method, StatusCode } from "../common"; +import { AnyApiResponses, Method, StatusCode } from "../core"; const toFastifyResponse = ( responses: Responses, diff --git a/src/fetch/index.t-test.ts b/src/fetch/index.t-test.ts index 94c76c9..9eefde4 100644 --- a/src/fetch/index.t-test.ts +++ b/src/fetch/index.t-test.ts @@ -1,4 +1,4 @@ -import { AsJsonApi, DefineApiEndpoints } from "../common"; +import { AsJsonApi, DefineApiEndpoints } from "../core"; import FetchT from "./index"; import JSONT from "../json"; const JSONT = JSON as JSONT; diff --git a/src/fetch/index.ts b/src/fetch/index.ts index 2f49d02..e02927a 100644 --- a/src/fetch/index.ts +++ b/src/fetch/index.ts @@ -13,8 +13,8 @@ import { StatusCode, IsAllOptional, CaseInsensitive, -} from "../common"; -import { UrlPrefixPattern, ToUrlParamPattern } from "../common"; +} from "../core"; +import { UrlPrefixPattern, ToUrlParamPattern } from "../core"; import { TypedString } from "../json"; export type RequestInitT< diff --git a/src/index.ts b/src/index.ts index 231092c..9e263e5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export * from "./common"; +export * from "./core"; export { asAsync as expressAsAsync, wrap as expressWrap, diff --git a/src/valibot/index.ts b/src/valibot/index.ts index 52e104f..9658d87 100644 --- a/src/valibot/index.ts +++ b/src/valibot/index.ts @@ -7,13 +7,13 @@ import { isMethod, Method, StatusCode, -} from "../common"; +} from "../core"; import { getApiSpec, Validator, Validators, ValidatorsInput, -} from "../common/validate"; +} from "../core/validate"; import { Result } from "../utils"; import { BaseIssue, diff --git a/src/zod/index.ts b/src/zod/index.ts index 5d0f34a..7e996ae 100644 --- a/src/zod/index.ts +++ b/src/zod/index.ts @@ -6,13 +6,13 @@ import { isMethod, Method, StatusCode, -} from "../common"; +} from "../core"; import { getApiSpec, Validator, Validators, ValidatorsInput, -} from "../common/validate"; +} from "../core/validate"; import { Result } from "../utils"; export const anyZ = () => z.any() as ZodType;