-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cletqui
committed
Jul 11, 2024
1 parent
166e910
commit a381b9f
Showing
10 changed files
with
205 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,40 @@ | ||
import { Context, Hono, Env } from "hono"; | ||
import { Context, Hono } from "hono"; | ||
|
||
import {} from ".."; | ||
import { Bindings, Variables } from ".."; | ||
import { handleTokens } from "../utils/tokens"; | ||
import { getMaxId, handleMaxId } from "../utils/octokit"; | ||
import { setCookie } from "hono/cookie"; | ||
|
||
/* APP */ | ||
const app = new Hono<Env>(); | ||
const app = new Hono<{ Bindings: Bindings; Variables: Variables }>(); | ||
|
||
/* MIDDLEWARES */ | ||
app.use(handleMaxId); | ||
app.use(handleTokens); | ||
|
||
/* ENDPOINTS */ | ||
app.get("/", async (c: Context<Env>): Promise<Response> => { | ||
const { | ||
max_id: { id, timestamp: old }, | ||
access_token, | ||
octokit, | ||
} = c.var; | ||
const update = access_token ? await getMaxId(octokit, id) : id; | ||
const timestamp = access_token ? new Date().getTime() : old; | ||
setCookie(c, "max_id", `{ "id": ${update}, "timestamp": ${timestamp} }`, { | ||
path: "/", | ||
secure: true, | ||
httpOnly: false, // true | ||
maxAge: 31557600, | ||
sameSite: "Strict", | ||
prefix: "secure", | ||
}); | ||
return c.json({ id: update, timestamp: timestamp }); | ||
}); | ||
app.get( | ||
"/", | ||
async ( | ||
c: Context<{ Bindings: Bindings; Variables: Variables }> | ||
): Promise<Response> => { | ||
const { | ||
max_id: { id, timestamp: old }, | ||
access_token, | ||
octokit, | ||
} = c.var; | ||
const update = access_token ? await getMaxId(octokit, id) : id; | ||
const timestamp = access_token ? new Date().getTime() : old; | ||
setCookie(c, "max_id", `{ "id": ${update}, "timestamp": ${timestamp} }`, { | ||
path: "/", | ||
secure: true, | ||
httpOnly: false, // true | ||
maxAge: 31557600, | ||
sameSite: "Strict", | ||
prefix: "secure", | ||
}); | ||
return c.json({ id: update, timestamp: timestamp }); | ||
} | ||
); | ||
|
||
export default app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
import { Context, Hono, Env } from "hono"; | ||
import { Context, Hono } from "hono"; | ||
|
||
import { Bindings, Variables } from ".."; | ||
import { Repository } from "../components/repository"; | ||
import { handleTokens } from "../utils/tokens"; | ||
import { getRepository } from "../utils/octokit"; | ||
|
||
/* APP */ | ||
const app = new Hono<Env>(); | ||
const app = new Hono<{ Bindings: Bindings; Variables: Variables }>(); | ||
|
||
/* MIDDLEWARES */ | ||
app.use(handleTokens); | ||
|
||
/* ENDPOINTS */ | ||
app.get("/", async (c: Context<Env>): Promise<Response> => { | ||
const { octokit } = c.var; | ||
const id = 811042081; // cletqui/petithub | ||
const repository = getRepository(octokit, id); | ||
return c.render(<Repository repository={repository} />, { repository }); | ||
}); | ||
app.get( | ||
"/", | ||
async ( | ||
c: Context<{ Bindings: Bindings; Variables: Variables }> | ||
): Promise<Response> => { | ||
const { octokit } = c.var; | ||
const id = 811042081; // cletqui/petithub | ||
const repository = getRepository(octokit, id); | ||
return c.render(<Repository repository={repository} />, { repository }); | ||
} | ||
); | ||
|
||
export default app; |
Oops, something went wrong.