Skip to content

Commit

Permalink
Merge pull request #66 from saiichihashimoto/revert
Browse files Browse the repository at this point in the history
fix(next): Revert "fix(next): export app router separately"
  • Loading branch information
kodiakhq[bot] authored Jun 7, 2024
2 parents 19902db + 0d10e60 commit 1495864
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const EmailQueue = Queue(
}
);

export const POST = EmailQueue.handler;
export const POST = EmailQueue;
```

Up top, we're importing `Queue`, which is a function that we use to declare a new Queue and export it as default.
Expand Down
4 changes: 2 additions & 2 deletions src/next-app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("next-app", () => {
process.nextTick(resolve);
});

queueResponse = await queue.handler({
queueResponse = await queue({
text: async () => body,
headers: new Headers({
"x-zeplo-id": "foo",
Expand Down Expand Up @@ -433,7 +433,7 @@ describe("next-app", () => {

it("calls queue inline instead of waiting with mode=direct", async () => {
fetchSpy.mockImplementation(async (input, { body, headers = {} } = {}) => {
queueResponse = await queue.handler({
queueResponse = await queue({
text: async () => body,
headers: new Headers({
...(!("X-Zeplo-Id" in headers)
Expand Down
13 changes: 8 additions & 5 deletions src/next-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ export const Queue = <Payload>(
) => {
const zeplo = ZeploClient({ handler, route, options });

return {
enqueue: async (payload: Payload, options?: EnqueueOptions<Payload>) =>
zeplo.enqueue(payload, options),
handler: (async (req) => {
// eslint-disable-next-line fp/no-mutating-assign -- HACK
return Object.assign(
(async (req) => {
const { status, body } = await zeplo.respondTo(
await req.text(),
Object.fromEntries(req.headers.entries())
Expand All @@ -28,5 +27,9 @@ export const Queue = <Payload>(
{ status }
);
}) satisfies (req: NextRequest) => Promise<NextResponse<string>>,
};
{
enqueue: async (payload: Payload, options?: EnqueueOptions<Payload>) =>
zeplo.enqueue(payload, options),
}
);
};

0 comments on commit 1495864

Please sign in to comment.