Skip to content

Commit

Permalink
refactor(rates.ts): refactor ShippingControllerRates function to use …
Browse files Browse the repository at this point in the history
…Azure Functions types and log request details

feat(rates.ts): return response as HttpResponseInit with jsonBody

fix(rates.spec.ts): fix indentation and formatting in shippingBody object
feat(rates.spec.ts): add additional item to shippingBody object for testing purposes

fix(rates.ts): fix import statement for mongoose connect function
fix(rates.ts): change body parameter name to rate in ShippingServiceRates function
fix(rates.ts): fix variable name in ShippingServiceRates function
fix(rates.ts): fix variable name in ShippingServiceRates function
fix(rates.ts): fix variable name in ShippingServiceRates function
fix(rates.ts): fix variable name in ShippingServiceRates function
fix(rates.ts): fix variable name in ShippingServiceRates function
fix(rates.ts): fix variable name in ShippingServiceRates function
fix(rates.ts): fix variable name in ShippingServiceRates function
fix(rates.ts): fix variable name in ShippingServiceRates function
fix(rates.ts): fix variable name in ShippingServiceRates function
fix(rates.ts): fix variable name in ShippingServiceRates function
fix(rates.ts): fix variable name in ShippingServiceRates function
fix(rates.ts): fix variable name in ShippingServiceRates
  • Loading branch information
jamalsoueidan committed Dec 12, 2023
1 parent 4ad1b4d commit e808ec0
Show file tree
Hide file tree
Showing 4 changed files with 279 additions and 268 deletions.
35 changes: 19 additions & 16 deletions src/functions/shipping/controllers/rates.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { _ } from "~/library/handler";
import {
HttpRequest,
HttpResponseInit,
InvocationContext,
} from "@azure/functions";
import { ShippingServiceRates } from "../services/rates";

import { ShippingBody, ShippingServiceRates } from "../services/rates";

export type ShippingControllerRatesRequest = {
body: ShippingBody;
};

export type ShippingControllerRatesResponse = Awaited<
ReturnType<typeof ShippingServiceRates>
>;

export const ShippingControllerRates = _(
async ({ body }: ShippingControllerRatesRequest) => {
return ShippingServiceRates(body);
}
);
export async function ShippingControllerRates(
request: HttpRequest,
context: InvocationContext
): Promise<HttpResponseInit> {
context.log(
`Http function processed request for url "${request.url}" ${request.method}`
);
const body = await request.json();
const jsonBody = await ShippingServiceRates(body as unknown as any);
return {
jsonBody,
};
}
Loading

0 comments on commit e808ec0

Please sign in to comment.