Skip to content

Commit

Permalink
refactor: use full relative paths
Browse files Browse the repository at this point in the history
This should help bring ESM compatibility in the future
  • Loading branch information
wolfy1339 committed May 28, 2021
1 parent 67ec3ff commit 2af81d4
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/event-handler/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createLogger } from "../createLogger";
import { createLogger } from "../createLogger.js";
import type {
EmitterWebhookEvent,
EmitterWebhookEventName,
Expand All @@ -11,9 +11,9 @@ import {
receiverOn as on,
receiverOnAny as onAny,
receiverOnError as onError,
} from "./on";
import { receiverHandle as receive } from "./receive";
import { removeListener } from "./remove-listener";
} from "./on.js";
import { receiverHandle as receive } from "./receive.js";
import { removeListener } from "./remove-listener.js";

interface EventHandler<TTransformed> {
on<E extends EmitterWebhookEventName>(
Expand Down
2 changes: 1 addition & 1 deletion src/event-handler/on.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { emitterEventNames } from "../generated/webhook-names";
import { emitterEventNames } from "../generated/webhook-names.js";
import {
EmitterWebhookEvent,
EmitterWebhookEventName,
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { sign, verify } from "@octokit/webhooks-methods";

import { createLogger } from "./createLogger";
import { createEventHandler } from "./event-handler/index";
import { verifyAndReceive } from "./verify-and-receive";
import { createLogger } from "./createLogger.js";
import { createEventHandler } from "./event-handler/index.js";
import { verifyAndReceive } from "./verify-and-receive.js";
import {
EmitterWebhookEvent,
EmitterWebhookEventName,
Expand All @@ -13,7 +13,7 @@ import {
WebhookEventHandlerError,
} from "./types";

export { createNodeMiddleware } from "./middleware/node/index";
export { createNodeMiddleware } from "./middleware/node/index.js";

// U holds the return value of `transform` function in Options
class Webhooks<TTransformed = unknown> {
Expand Down
8 changes: 4 additions & 4 deletions src/middleware/node/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createLogger } from "../../createLogger";
import { Webhooks } from "../../index";
import { middleware } from "./middleware";
import { onUnhandledRequestDefault } from "./on-unhandled-request-default";
import { createLogger } from "../../createLogger.js";
import { Webhooks } from "../../index.js";
import { middleware } from "./middleware.js";
import { onUnhandledRequestDefault } from "./on-unhandled-request-default.js";
import { MiddlewareOptions } from "./types";

export function createNodeMiddleware(
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/node/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
type IncomingMessage = any;
type ServerResponse = any;

import { Logger } from "../../createLogger";
import { Logger } from "../../createLogger.js";

export type MiddlewareOptions = {
path?: string;
Expand Down
7 changes: 5 additions & 2 deletions test/integration/event-handler-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { createEventHandler } from "../../src/event-handler";
import { createEventHandler } from "../../src/event-handler/index.js";
import { EmitterWebhookEvent, WebhookEventHandlerError } from "../../src/types";
import { installationCreatedPayload, pushEventPayload } from "../fixtures";
import {
installationCreatedPayload,
pushEventPayload,
} from "../fixtures/index.js";

test("events", async () => {
const eventHandler = createEventHandler({});
Expand Down
4 changes: 2 additions & 2 deletions test/integration/node-middleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { sign } from "@octokit/webhooks-methods";
// import without types
const express = require("express");

import { Webhooks, createNodeMiddleware } from "../../src";
import { pushEventPayload } from "../fixtures";
import { Webhooks, createNodeMiddleware } from "../../src/index.js";
import { pushEventPayload } from "../fixtures/index.js";

let signatureSha256: string;

Expand Down
2 changes: 1 addition & 1 deletion test/integration/smoke-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Webhooks, createEventHandler } from "../../src";
import { Webhooks, createEventHandler } from "../../src/index.js";

test("@octokit/webhooks", () => {
const emitWarningSpy = jest.spyOn(process, "emitWarning");
Expand Down
2 changes: 1 addition & 1 deletion test/integration/webhooks.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Webhooks, EmitterWebhookEvent } from "../../src";
import { Webhooks, EmitterWebhookEvent } from "../../src/index.js";

describe("Webhooks", () => {
test("new Webhooks() without secret option", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/typescript-validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
EmitterWebhookEvent,
WebhookError,
createNodeMiddleware,
} from "../src/index";
} from "../src/index.js";
import { createServer } from "http";
import { HandlerFunction, EmitterWebhookEventName } from "../src/types";

Expand Down
2 changes: 1 addition & 1 deletion test/unit/createLogger-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createLogger } from "../../src/createLogger";
import { createLogger } from "../../src/createLogger.js";

const noop = () => {};

Expand Down
2 changes: 1 addition & 1 deletion test/unit/event-handler-on-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { receiverOn } from "../../src/event-handler/on";
import { receiverOn } from "../../src/event-handler/on.js";
import { State } from "../../src/types";

function noop() {}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/event-handler-receive-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { receiverHandle as receive } from "../../src/event-handler/receive";
import { receiverHandle as receive } from "../../src/event-handler/receive.js";
import { State } from "../../src/types";

const state: State = {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/event-handler-remove-listener-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { removeListener } from "../../src/event-handler/remove-listener";
import { removeListener } from "../../src/event-handler/remove-listener.js";
import { State } from "../../src/types";

test("remove-listener: single listener", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/event-handler-wrap-error-handler-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { wrapErrorHandler } from "../../src/event-handler/wrap-error-handler";
import { wrapErrorHandler } from "../../src/event-handler/wrap-error-handler.js";

const noop = () => {};

Expand Down

0 comments on commit 2af81d4

Please sign in to comment.