Skip to content

Commit 11711a8

Browse files
committed
Removing unnecessary async/await keywords
1 parent bf80467 commit 11711a8

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "labelzoom-cf-api-proxy",
33
"description": "A Cloudflare Worker that serves as a reverse proxy for LabelZoom's public REST API",
4-
"version": "1.1.0",
4+
"version": "1.1.1",
55
"private": true,
66
"dependencies": {
77
"hono": "4.7.7",

src/worker/handlers/proxy-to-backend.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export const proxyToBackend = ({
1212
}: ProxyToBackendOptions = {}): NotFoundHandler => {
1313
if (!baseUrl) throw new Error('proxy-to-backend handler requires baseUrl');
1414

15-
return async (c) => {
15+
return (c) => {
1616
const url = new URL(c.req.url);
1717
const backendUrl = baseUrl + url.pathname + url.search;
18-
return await proxy(backendUrl, {
18+
return proxy(backendUrl, {
1919
...c.req,
2020
redirect: 'manual',
2121
headers: {

src/worker/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async function verifyTokenAndLicense(token: string, c: Context) {
3434
const app = new Hono<{ Bindings: Env }>();
3535

3636
//#region Middleware for all API requests
37-
app.use("/api/*", async (c, next) => {
37+
app.use("/api/*", (c, next) => {
3838
return cors({
3939
origin: c.env.LZ_ALLOWED_ORIGINS,
4040
allowHeaders: [],
@@ -58,7 +58,7 @@ app.use("/api/*", async (c, next) => {
5858
//#endregion
5959

6060
//#region URL-to-ZPL conversions
61-
app.use("/api/v2/convert/url/to/zpl/*", async (c, next) => {
61+
app.use("/api/v2/convert/url/to/zpl/*", (c, next) => {
6262
return every(
6363
hyperdriveMysql({
6464
config: c.env.DB,
@@ -69,11 +69,11 @@ app.use("/api/v2/convert/url/to/zpl/*", async (c, next) => {
6969
})
7070
)(c, next);
7171
});
72-
app.get("/api/v2/convert/url/to/zpl/:url{.+}", async (c) => proxy(c.req.param('url')));
72+
app.get("/api/v2/convert/url/to/zpl/:url{.+}", (c) => proxy(c.req.param('url')));
7373
//#endregion
7474

7575
//#region All other conversions
76-
app.use("/api/v2/convert/:sourceFormat/to/:targetFormat", async (c, next) => {
76+
app.use("/api/v2/convert/:sourceFormat/to/:targetFormat", (c, next) => {
7777
return every(
7878
requestId({
7979
headerName: 'X-LZ-Request-Id',
@@ -96,7 +96,7 @@ app.use(async (c, next) => {
9696
}
9797
await next();
9898
});
99-
app.notFound(async (c) => {
99+
app.notFound((c) => {
100100
return proxyToBackend({
101101
baseUrl: c.env.LZ_PROD_API_BASE_URL,
102102
headers: {

src/worker/middleware/hyperdrive-mysql/hyperdrive-mysql.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @module
3-
* Cloudflare Hyperdrive Middleware for Hono.
3+
* Cloudflare Hyperdrive (MySQL) Middleware for Hono.
44
*/
55

66
import mysql from 'mysql2/promise';
@@ -13,8 +13,8 @@ export type Connection = mysql.Connection & {
1313
query(sql: string, values: any): Promise<[mysql.OkPacket | mysql.ResultSetHeader | mysql.RowDataPacket[] | mysql.RowDataPacket[][] | mysql.OkPacket[], mysql.FieldPacket[]]>;
1414
};
1515

16-
async function getConnection(hyperdrive: Hyperdrive): Promise<Connection> {
17-
return (await mysql.createConnection({
16+
function getConnection(hyperdrive: Hyperdrive): Promise<Connection> {
17+
return (mysql.createConnection({
1818
host: hyperdrive.host,
1919
user: hyperdrive.user,
2020
password: hyperdrive.password,
@@ -25,7 +25,7 @@ async function getConnection(hyperdrive: Hyperdrive): Promise<Connection> {
2525
// mysql2 uses eval() to optimize result parsing for rows with > 100 columns
2626
// Configure mysql2 to use static parsing instead of eval() parsing with disableEval
2727
disableEval: true,
28-
}) as Connection);
28+
}) as Promise<Connection>);
2929
}
3030

3131
export type HyperdriveVariables = {
@@ -37,7 +37,7 @@ export type HyperdriveOptions = {
3737
};
3838

3939
/**
40-
* Cloudflare Hyperdrive Middleware for Hono.
40+
* Cloudflare Hyperdrive (MySQL) Middleware for Hono.
4141
* @param options
4242
* @returns
4343
*/

0 commit comments

Comments
 (0)