-
Notifications
You must be signed in to change notification settings - Fork 21
/
.aegir.js
62 lines (59 loc) · 1.4 KB
/
.aegir.js
1
2
3
4
5
6
7
8
9
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import http from 'node:http'
import fs from 'node:fs'
export default {
tsRepo: false,
dependencyCheck: {
input: [
'dist/**/*.js',
],
productionInput: [
'dist/**/*.js',
],
},
build: {
config: {
format: 'esm',
banner: {
js: ''
},
footer: {
js: ''
}
}
},
test: {
before: async (...args) => {
// set up a server to serve the fixtures
const server = http.createServer((req, res) => {
const cidString = req.url.replace('/ipfs/', '').split('?')[0]
const mockBlock = fs.readFileSync(`./test/fixtures/${cidString}.raw.bin`, null)
res.writeHead(200, {
'access-control-allow-origin': '*', // allow CORS requests
'Content-Type': 'application/vnd.ipld.raw',
'Content-Length': mockBlock.length
})
res.end(mockBlock)
})
let gwUrl = process.env.IPFS_GATEWAY
if (!gwUrl) {
// no gateway specified, start the server
await new Promise((resolve, _reject) => {
server.listen(0, () => {
gwUrl = `http://localhost:${server.address().port}`
console.log(`server listening at ${gwUrl}`)
resolve()
})
})
}
return {
server,
env: {
IPFS_GATEWAY: gwUrl,
}
}
},
after: (_, before) => {
before.server.close()
}
}
}