James
02/22/2023, 7:23 PMassets
, you could exclude that folder from running any functions using `_routes`: https://developers.cloudflare.com/pages/platform/functions/routing/#functions-invocation-routesNoodles
02/22/2023, 8:43 PMFound Functions directory at /functions. Uploading.
12:36:37.272
12:36:37.386 ✘ [ERROR] No routes found when building Functions directory: /opt/buildhome/repo/functions
Warning: Wrangler did not find routes when building functions. Skipping.
12:36:37.400 Found _routes.json in output directory. Uploading.
12:36:37.423 Validating asset output directory
I have attached the KV namespace to the project for the function, but it seems like it just won't build the function at all.
Functions folder is created and _routes.json is present.
Pause
02/22/2023, 8:44 PMPause
02/22/2023, 8:44 PMPause
02/22/2023, 9:40 PMPause
02/22/2023, 9:42 PMindexOf
to see if text/html
is in therePause
02/22/2023, 9:42 PMtext/html
I could probably do an equality comparisonSkye
02/22/2023, 9:42 PMkian
02/22/2023, 9:42 PMkian
02/22/2023, 9:43 PMPause
02/22/2023, 9:44 PMJoão Castro
02/23/2023, 6:52 AMHardAtWork
02/23/2023, 8:43 AMLor
02/23/2023, 9:10 AMjs
Error: Type 'function' not supported for value 'function(block) {
return block(this);
}'
Code
ts
let prepare = this.DB.prepare("INSERT INTO users (email, password, salt, id) VALUES (?, ?, ?, ?)");
let command = prepare.bind(email, password, salt, id);
Skye
02/23/2023, 9:32 AMLor
02/23/2023, 9:33 AMSkye
02/23/2023, 9:37 AMLor
02/23/2023, 9:49 AMSkye
02/23/2023, 9:51 AMSkye
02/23/2023, 9:51 AMLor
02/23/2023, 9:59 AMts
export interface Env {
DATABASE: D1Database;
PEPPER: string;
}
ts
export class UserDB {
DB: D1Database;
constructor(db: D1Database) {
this.DB = db;
}
async createUser(email: string, password: string, salt: string, id: string): Promise<User> {
console.log("preparing command")
let prepare = this.DB.prepare("INSERT INTO users (email, password, salt, id) VALUES (?, ?, ?, ?)");
let command = prepare.bind(email.toString(), password.toString(), salt.toString(), id.toString()); // Throws here
await command.run();
return await this.getUser(id)
}
}
ts
export const onRequestPost: PagesFunction<Env> = async (context) => {
let {email, password, challenge} = await context.request.json<{
email: string, password: string, challenge: string
}>();
// Validation here
let db = new UserDB(context.env.DATABASE)
let salt: string = Buffer.from(crypto.getRandomValues(new Uint8Array(16))).toString('base64');
let id: string = uuidv4();
let hashedPassword: string = SHA512(salt + password + context.env.PEPPER).toString(CryptoJS.enc.Hex);
let result = await db.createUser(email, hashedPassword, salt, id); // Throws here
}
Skye
02/23/2023, 10:00 AMSkye
02/23/2023, 10:01 AMfunction(block) {
return block(this);
}
in the message, even with the .toString()?Lor
02/23/2023, 10:01 AMSkye
02/23/2023, 10:01 AMLor
02/23/2023, 10:02 AMLor
02/23/2023, 10:02 AMSkye
02/23/2023, 10:02 AMLor
02/23/2023, 10:08 AM