Skip to content

Commit

Permalink
fix confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaldesigndj committed Jul 29, 2023
1 parent 46a9027 commit a13ec24
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
35 changes: 17 additions & 18 deletions routes/_middleware.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,35 @@ export async function handler(req, ctx) {
]
let resp
if (
withSession.includes(pathname) ||
pathname.startsWith("/api/")
withSession.includes(pathname)
) {
// ctx.API_URL = API_URL;
ctx.BASE_URL = BASE_URL
ctx.CURRENT_ENV = CURRENT_ENV
// ctx.store = store
resp = session(req, ctx)
resp = await session(req, ctx)
} else {
resp = await ctx.next()
}
const now = Date.now()
const ms = now - start
// const status = () => {
// const str = resp.status.toString()
// console.log(str)
// if (str[0] === "2") {
// return green(str)
// }
// if (str[0] === "3") {
// return yellow(str)
// } else {
// return red(str)
// }
// }
const status = () => {
if (resp.status === undefined) {
return yellow("?")
}
const str = resp.status.toString()
if (str[0] === "2") {
return green(str)
}
if (str[0] === "3") {
return yellow(str)
} else {
return red(str)
}
}
// resp.headers.set("X-Response-Time", `${ms}ms`)
console.log(
`[${magenta(new Date(now).toISOString())}] ${blue(req.method)} ${
cyan(pathname)
} - ${blue(String(ms) + "ms")} - ${resp.status}`,
} - ${blue(String(ms) + "ms")} - ${status()}`,
)
return resp
}
5 changes: 1 addition & 4 deletions routes/draw.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const handler = {
POST: async (req, ctx) => {
const { session } = ctx.state
const data = await req.formData()
console.log(data)
// console.log(data)
// const deck = getNewCards();
// const deck_id = crypto.randomUUID();
// const cards = deck.splice(0, 5);
Expand Down Expand Up @@ -59,9 +59,6 @@ export const handler = {
session.set("streak", 0)
ctx.state.streak = 0
}
// ctx.store.set(ctx.REDIS_KEY, JSON.stringify({ ...ctx.state }))
session.set(ctx.REDIS_KEY, JSON.stringify({ ...ctx.state }))
// ctx.store.expire(`deck-${deck_id}`, 0)
session.set(`deck-${deck_id}`, null)
return ctx.render({
...ctx.state,
Expand Down

0 comments on commit a13ec24

Please sign in to comment.