spooder 4.4.6 → 4.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/package.json +1 -1
- package/src/api.ts +8 -4
package/README.md
CHANGED
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -400,13 +400,14 @@ export async function db_init_schema_mysql(db_info: mysql_types.ConnectionOption
|
|
|
400
400
|
return await _db_init_schema_mysql(db_info, schema_dir, false) as mysql_types.Connection;
|
|
401
401
|
}
|
|
402
402
|
|
|
403
|
-
type CookieOptions = {
|
|
403
|
+
export type CookieOptions = {
|
|
404
404
|
same_site?: 'Strict' | 'Lax' | 'None',
|
|
405
405
|
secure?: boolean,
|
|
406
406
|
http_only?: boolean,
|
|
407
407
|
path?: string,
|
|
408
408
|
expires?: number,
|
|
409
|
-
encode?: boolean
|
|
409
|
+
encode?: boolean,
|
|
410
|
+
max_age?: number
|
|
410
411
|
};
|
|
411
412
|
|
|
412
413
|
export function set_cookie(res: Response, name: string, value: string, options?: CookieOptions): void {
|
|
@@ -430,6 +431,9 @@ export function set_cookie(res: Response, name: string, value: string, options?:
|
|
|
430
431
|
const date = new Date(Date.now() + options.expires);
|
|
431
432
|
cookie += '; Expires=' + date.toUTCString();
|
|
432
433
|
}
|
|
434
|
+
|
|
435
|
+
if (options.max_age !== undefined)
|
|
436
|
+
cookie += '; Max-Age=' + options.max_age;
|
|
433
437
|
} else {
|
|
434
438
|
cookie += value;
|
|
435
439
|
}
|
|
@@ -547,7 +551,7 @@ function route_directory(route_path: string, dir: string, handler: DirHandler):
|
|
|
547
551
|
};
|
|
548
552
|
}
|
|
549
553
|
|
|
550
|
-
export function validate_req_json(
|
|
554
|
+
export function validate_req_json(json_handler: JSONRequestHandler): RequestHandler {
|
|
551
555
|
return async (req: Request, url: URL) => {
|
|
552
556
|
try {
|
|
553
557
|
// validate content type header
|
|
@@ -560,7 +564,7 @@ export function validate_req_json(JSONRequestHandler: JSONRequestHandler): Reque
|
|
|
560
564
|
if (json === null || typeof json !== 'object' || Array.isArray(json))
|
|
561
565
|
return 400; // Bad Request
|
|
562
566
|
|
|
563
|
-
return
|
|
567
|
+
return json_handler(req, url, json);
|
|
564
568
|
} catch (e) {
|
|
565
569
|
return 400; // Bad Request
|
|
566
570
|
}
|