Download src/security/featureExtractor.js from TwanAPI/trsstapi: direct link, hf CLI and curl.
- Browser
- Download file 319 Bytes
-
https://huggingface.co/spaces/TwanAPI/trsstapi/resolve/de2e0fefcfcbbc7b9f08d2b8c25aeab664668cd4/src/security/featureExtractor.js
- Command line
-
hf download hf://spaces/TwanAPI/trsstapi@de2e0fefcfcbbc7b9f08d2b8c25aeab664668cd4/src/security/featureExtractor.js
-
curl -L -o featureExtractor.js https://huggingface.co/spaces/TwanAPI/trsstapi/resolve/de2e0fefcfcbbc7b9f08d2b8c25aeab664668cd4/src/security/featureExtractor.js
319 Bytes
| import { AuditLog } from "../models/AuditLog.js"; | |
| export async function extractFeatures(log) { | |
| const since = new Date(Date.now() - 10 * 60 * 1000); | |
| const ipCount = await AuditLog.countDocuments({ | |
| ip: log.ip, | |
| createdAt: { $gte: since }, | |
| }); | |
| return [log.createdAt.getHours(), Math.min(ipCount, 100)]; | |
| } | |