01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { SecureChannel, QueryBuilder, CacheLayer } from '@polygonfox/core';
import { RateLimiter, CSRFGuard, InputSanitizer } from '@polygonfox/security';
import { PageSpeedOptimizer, LazyLoader } from '@polygonfox/performance';
export class PolygonEngine {
constructor(config) {
this.db = new SecureChannel({ encryption: 'AES-256-GCM', host: config.dbHost });
this.cache = new CacheLayer({ ttl: 3600, strategy: 'lru' });
this.guard = new CSRFGuard();
this.limiter = new RateLimiter({ max: 100, windowMs: 60_000 });
this.perf = new PageSpeedOptimizer({ target: 95 });
}
async handleRequest(req) {
await this.guard.verify(req.token);
await this.limiter.check(req.ip);
const clean = InputSanitizer.sanitize(req.body);
const cached = await this.cache.get(clean.cacheKey);
if (cached) return cached;
const result = await new QueryBuilder(this.db)
.select('*')
.from(clean.resource)
.where(clean.filters)
.execute();
await this.cache.set(clean.cacheKey, result);
return this.perf.optimize(result);
}
}
export default new PolygonEngine({ dbHost: 'db.polygonfox.dev' });
import { SecureChannel, QueryBuilder, CacheLayer } from '@polygonfox/core';
import { RateLimiter, CSRFGuard, InputSanitizer } from '@polygonfox/security';
import { PageSpeedOptimizer, LazyLoader } from '@polygonfox/performance';
export class PolygonEngine {
constructor(config) {
this.db = new SecureChannel({ encryption: 'AES-256-GCM', host: config.dbHost });
this.cache = new CacheLayer({ ttl: 3600, strategy: 'lru' });
this.guard = new CSRFGuard();
this.limiter = new RateLimiter({ max: 100, windowMs: 60_000 });
this.perf = new PageSpeedOptimizer({ target: 95 });
}
async handleRequest(req) {
await this.guard.verify(req.token);
await this.limiter.check(req.ip);
const clean = InputSanitizer.sanitize(req.body);
const cached = await this.cache.get(clean.cacheKey);
if (cached) return cached;
const result = await new QueryBuilder(this.db)
.select('*')
.from(clean.resource)
.where(clean.filters)
.execute();
await this.cache.set(clean.cacheKey, result);
return this.perf.optimize(result);
}
}
export default new PolygonEngine({ dbHost: 'db.polygonfox.dev' });