Skip to content

Commit

Permalink
fix: download count updating
Browse files Browse the repository at this point in the history
  • Loading branch information
dromzeh committed Aug 7, 2023
1 parent 370221e commit 3c05f4e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Source code for the API powering [**wanderer.moe**](https://wanderer.moe) — us

Configuration is in `wrangler.toml`.

You will require either a workers paid plan **or to set your worker to unbound** for authentication and password hashing to work.

You will need to setup environment variables for the Discord Bot Token for `/contributors` route: `DISCORD_TOKEN` and for Planetscale, using `wrangler secret put`.

- Run `wrangler dev` to preview locally.
Expand Down
2 changes: 1 addition & 1 deletion drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
breakpoints: true,
driver: "mysql2",
dbCredentials: {
host: process.env.DATABASE_HOST! || "",
host: process.env.DATABASE_HOST || "",
user: process.env.DATABASE_USERNAME || "",
password: process.env.DATABASE_PASSWORD || "",
database: "planetscale",
Expand Down
2 changes: 1 addition & 1 deletion src/routes/asset/downloadAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const downloadAsset = async (c: Context) => {
const blob = await response.blob();

await db.execute(
"UPDATE assets SET downloads = downloads + 1 WHERE id = ?",
"UPDATE assets SET download_count = download_count + 1 WHERE id = ?",
[assetId]
);

Expand Down
3 changes: 2 additions & 1 deletion src/routes/auth/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ export const login = async (c: Context): Promise<Response> => {

setCookie(c, authorizationTokenNames.csrf, newSession.sessionId, {
expires: newSession.activePeriodExpiresAt,
sameSite: "Lax",
httpOnly: true,
path: "/",
secure: true,
// sameSite: "Lax",
});

return c.json({ success: true, state: "logged in" }, 200);
Expand Down
4 changes: 2 additions & 2 deletions src/routes/auth/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ export const signup = async (c: Context) => {
expires: newSession.activePeriodExpiresAt,
httpOnly: true,
secure: true,
// sameSite: "Lax",
sameSite: "Lax",
});

return c.json({ success: true, tate: "logged in" }, 200);
return c.json({ success: true, state: "logged in" }, 200);
} catch (e) {
if (e instanceof LuciaError) {
return c.json(
Expand Down

0 comments on commit 3c05f4e

Please sign in to comment.