MCPcopy Create free account
hub / github.com/dev-mastery/comments-api / buildMakeSource

Function buildMakeSource

src/comment/source.js:1–15  ·  view source on GitHub ↗
({ isValidIp })

Source from the content-addressed store, hash-verified

1export default function buildMakeSource ({ isValidIp }) {
2 return function makeSource ({ ip, browser, referrer } = {}) {
3 if (!ip) {
4 throw new Error('Comment source must contain an IP.')
5 }
6 if (!isValidIp(ip)) {
7 throw new RangeError('Comment source must contain a valid IP.')
8 }
9 return Object.freeze({
10 getIp: () => ip,
11 getBrowser: () => browser,
12 getReferrer: () => referrer
13 })
14 }
15}

Callers 1

index.jsFile · 0.85

Calls 1

isValidIpFunction · 0.85

Tested by

no test coverage detected