Skip to content

Commit

Permalink
📦 update imports
Browse files Browse the repository at this point in the history
  • Loading branch information
w3cj committed Oct 16, 2024
1 parent d2c46cd commit ed0f0bd
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 35 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ Create a json content / schema description where the schema can be [oneOf](https

```ts
import { z } from "@hono/zod-openapi";
import createErrorSchema from "stocker/openapi/schemas/create-error-schema";
import jsonContentOneOf from "stoker/openapi/helpers/json-content-one-of";
import createErrorSchema from "stoker/openapi/schemas/create-error-schema";
import IdParamsSchema from "stoker/openapi/schemas/id-params";

const bodySchema = z.object({
Expand Down Expand Up @@ -323,8 +323,8 @@ Used internally by `stoker/openapi/helpers/json-content-one-of` but exported her

```ts
import { z } from "@hono/zod-openapi";
import createErrorSchema from "stocker/openapi/schemas/create-error-schema";
import oneOf from "stoker/openapi/helpers/one-of";
import createErrorSchema from "stoker/openapi/schemas/create-error-schema";
import IdParamsSchema from "stoker/openapi/schemas/id-params";

const bodySchema = z.object({
Expand Down Expand Up @@ -512,9 +512,9 @@ Create an example error schema with zod error / validation messages based on giv

```ts
import { createRoute, z } from "@hono/zod-openapi";
import createErrorSchema from "stocker/openapi/schemas/create-error-schema";
import * as HttpStatusCodes from "stoker/http-status-codes";
import jsonContent from "stoker/openapi/helpers/json-content";
import createErrorSchema from "stoker/openapi/schemas/create-error-schema";

const TaskSchema = z.object({
name: z.string(),
Expand Down
5 changes: 2 additions & 3 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ export default antfu({
indent: 2,
semi: true,
quotes: "double",
overrides: {
"func-style": ["error", "expression"],
},
},
}, {
rules: {
"func-style": ["error", "expression"],
"import/extensions": ["error", "ignorePackages"],
"ts/explicit-function-return-type": ["off"],
"perfectionist/sort-imports": ["error", {
internalPattern: ["@/**"],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stoker",
"type": "module",
"version": "1.2.5",
"version": "1.2.6",
"packageManager": "pnpm@9.9.0",
"description": "Utilities for hono and @hono/zod-openapi",
"author": "w3cj <cj@null.computer>",
Expand Down
4 changes: 2 additions & 2 deletions scripts/update-http-statuses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface JsonCode {
isDeprecated?: boolean;
}

async function run() {
const run = async () => {
console.log("Updating src/http-status-codes.ts and src/http-status-phrases.ts");

const project = new Project({
Expand Down Expand Up @@ -88,6 +88,6 @@ async function run() {
await project.save();
await execSync("npx eslint --fix ./src/http-status-codes.ts ./src/http-status-phrases.ts");
console.log("Successfully generated src/http-status-codes.ts and src/http-status-phrases.ts");
}
};

run();
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * as middlewares from "./middlewares";
export * as openapi from "./openapi";
export * as middlewares from "./middlewares/index.js";
export * as openapi from "./openapi/index.js";
6 changes: 3 additions & 3 deletions src/middlewares/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { default as notFound } from "./not-found";
export { default as onError } from "./on-error";
export { default as serveEmojiFavicon } from "./serve-emoji-favicon";
export { default as notFound } from "./not-found.js";
export { default as onError } from "./on-error.js";
export { default as serveEmojiFavicon } from "./serve-emoji-favicon.js";
4 changes: 2 additions & 2 deletions src/middlewares/not-found.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NotFoundHandler } from "hono";

import { NOT_FOUND } from "../http-status-codes";
import { NOT_FOUND as NOT_FOUND_MESSAGE } from "../http-status-phrases";
import { NOT_FOUND } from "../http-status-codes.js";
import { NOT_FOUND as NOT_FOUND_MESSAGE } from "../http-status-phrases.js";

const notFound: NotFoundHandler = (c) => {
return c.json({
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/on-error.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from "node:path";
import { describe, expect, it } from "vitest";

import onError from "./on-error";
import onError from "./on-error.js";

describe("onError", () => {
it("should use NODE_ENV from context if defined", async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/on-error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ErrorHandler } from "hono";
import type { StatusCode } from "hono/utils/http-status";

import { INTERNAL_SERVER_ERROR, OK } from "../http-status-codes";
import { INTERNAL_SERVER_ERROR, OK } from "../http-status-codes.js";

const onError: ErrorHandler = (err, c) => {
const currentStatus = "status" in err
Expand Down
2 changes: 1 addition & 1 deletion src/openapi/default-hook.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Hook } from "@hono/zod-openapi";

import { UNPROCESSABLE_ENTITY } from "../http-status-codes";
import { UNPROCESSABLE_ENTITY } from "../http-status-codes.js";

const defaultHook: Hook<any, any, any, any> = (result, c) => {
if (!result.success) {
Expand Down
8 changes: 4 additions & 4 deletions src/openapi/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { default as jsonContent } from "./json-content";
export { default as jsonContentOneOf } from "./json-content-one-of";
export { default as jsonContentRequired } from "./json-content-required";
export { default as oneOf } from "./one-of";
export { default as jsonContent } from "./json-content.js";
export { default as jsonContentOneOf } from "./json-content-one-of.js";
export { default as jsonContentRequired } from "./json-content-required.js";
export { default as oneOf } from "./one-of.js";
2 changes: 1 addition & 1 deletion src/openapi/helpers/json-content-one-of.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { z } from "@hono/zod-openapi";
import { describe, expect, it } from "vitest";

import jsonContentOneOf from "./json-content-one-of";
import jsonContentOneOf from "./json-content-one-of.js";

describe("jsonContentOneOf", () => {
it("accepts a single schema", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/openapi/helpers/json-content-one-of.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ZodSchema } from "./types";

import oneOf from "./one-of";
import oneOf from "./one-of.js";

const jsonContentOneOf = <
T extends ZodSchema,
Expand Down
2 changes: 1 addition & 1 deletion src/openapi/helpers/json-content-required.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ZodSchema } from "./types";

import jsonContent from "./json-content";
import jsonContent from "./json-content.js";

const jsonContentRequired = <
T extends ZodSchema,
Expand Down
6 changes: 3 additions & 3 deletions src/openapi/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { default as defaultHook } from "./default-hook";
export * as helpers from "./helpers";
export * as schemas from "./schemas";
export { default as defaultHook } from "./default-hook.js";
export * as helpers from "./helpers/index.js";
export * as schemas from "./schemas/index.js";
10 changes: 5 additions & 5 deletions src/openapi/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { default as createErrorSchema } from "./create-error-schema";
export { default as createMessageObjectSchema } from "./create-message-object";
export { default as IdParamsSchema } from "./id-params";
export { default as IdUUIDParamsSchema } from "./id-uuid-params";
export { default as SlugParamsSchema } from "./slug-params";
export { default as createErrorSchema } from "./create-error-schema.js";
export { default as createMessageObjectSchema } from "./create-message-object.js";
export { default as IdParamsSchema } from "./id-params.js";
export { default as IdUUIDParamsSchema } from "./id-uuid-params.js";
export { default as SlugParamsSchema } from "./slug-params.js";
2 changes: 1 addition & 1 deletion src/openapi/schemas/slug-params.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";

import SlugParamsSchema from "./slug-params";
import SlugParamsSchema from "./slug-params.js";

describe("slug-params", () => {
it("allows letters", () => {
Expand Down

0 comments on commit ed0f0bd

Please sign in to comment.