refactor: update import statements to use node built-ins
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs/promises";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import Cap from "@cap.js/server";
|
||||
import crypto from "crypto";
|
||||
import Elysia from "elysia";
|
||||
|
||||
import { dirname, join } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
export const capMiddleware = (userOptions) => {
|
||||
const options = {
|
||||
token_validity_hours: 32,
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs/promises";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import Cap from "@cap.js/server";
|
||||
import crypto from "crypto";
|
||||
|
||||
import { dirname, join } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
export const capCheckpoint = (userOptions) => {
|
||||
const options = {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs/promises";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import Cap from "@cap.js/server";
|
||||
import crypto from "crypto";
|
||||
import { getCookie, setCookie } from "hono/cookie";
|
||||
import { createMiddleware } from "hono/factory";
|
||||
|
||||
import { dirname, join } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
export const capCheckpoint = (userOptions) => {
|
||||
const options = {
|
||||
token_validity_hours: 32,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { Elysia, file } from "elysia";
|
||||
import { capMiddleware } from "../../../checkpoints/elysia/index";
|
||||
|
||||
// import { capMiddleware } from "@cap.js/middleware-elysia";
|
||||
|
||||
new Elysia()
|
||||
.use(
|
||||
capMiddleware({
|
||||
/*
|
||||
.use(
|
||||
capMiddleware({
|
||||
/*
|
||||
token_validity_hours: 32, // how long the token is valid for
|
||||
tokens_store_path: ".data/tokensList.json",
|
||||
token_size: 16, // token size in bytes
|
||||
@@ -15,7 +16,7 @@ new Elysia()
|
||||
),
|
||||
scoping: "scoped", // 'global' | 'scoped'
|
||||
*/
|
||||
})
|
||||
)
|
||||
.get("/", () => file("success.html"))
|
||||
.listen(3000);
|
||||
}),
|
||||
)
|
||||
.get("/", () => file("success.html"))
|
||||
.listen(3000);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import express from "express";
|
||||
import path, { dirname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import cookieParser from "cookie-parser";
|
||||
import path from "path";
|
||||
import { dirname } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import express from "express";
|
||||
import { capCheckpoint } from "../../../checkpoints/express/index";
|
||||
|
||||
// import { capCheckpoint } from "@cap.js/checkpoint-express";
|
||||
|
||||
const app = express();
|
||||
@@ -13,20 +13,20 @@ app.use(express.json());
|
||||
app.use(cookieParser());
|
||||
|
||||
app.use(
|
||||
capCheckpoint({
|
||||
/*
|
||||
capCheckpoint({
|
||||
/*
|
||||
token_validity_hours: 32,
|
||||
tokens_store_path: ".data/tokensList.json",
|
||||
token_size: 16,
|
||||
verification_template_path: join(__dirname, "./index.html"),
|
||||
*/
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
res.sendFile(path.join(__dirname, "success.html"));
|
||||
app.get("/", (_, res) => {
|
||||
res.sendFile(path.join(__dirname, "success.html"));
|
||||
});
|
||||
|
||||
app.listen(3000, () => {
|
||||
console.log(`Server running on http://localhost:3000`);
|
||||
console.log(`Server running on http://localhost:3000`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user