@bsv/overlay-express 0.1.0
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/LICENSE.txt +28 -0
- package/README.md +38 -0
- package/dist/cjs/mod.js +9 -0
- package/dist/cjs/mod.js.map +1 -0
- package/dist/cjs/package.json +59 -0
- package/dist/cjs/src/OverlayExpress.js +556 -0
- package/dist/cjs/src/OverlayExpress.js.map +1 -0
- package/dist/cjs/src/makeUserInterface.js +208 -0
- package/dist/cjs/src/makeUserInterface.js.map +1 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/esm/mod.js +2 -0
- package/dist/esm/mod.js.map +1 -0
- package/dist/esm/src/OverlayExpress.js +523 -0
- package/dist/esm/src/OverlayExpress.js.map +1 -0
- package/dist/esm/src/makeUserInterface.js +206 -0
- package/dist/esm/src/makeUserInterface.js.map +1 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/types/mod.d.ts +2 -0
- package/dist/types/mod.d.ts.map +1 -0
- package/dist/types/src/OverlayExpress.d.ts +137 -0
- package/dist/types/src/OverlayExpress.d.ts.map +1 -0
- package/dist/types/src/makeUserInterface.d.ts +3 -0
- package/dist/types/src/makeUserInterface.d.ts.map +1 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -0
- package/mod.ts +1 -0
- package/package.json +74 -0
- package/src/OverlayExpress.ts +586 -0
- package/src/__tests/OverlayExpress.test.ts +0 -0
- package/src/makeUserInterface.ts +205 -0
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const express_1 = __importDefault(require("express"));
|
|
40
|
+
const body_parser_1 = __importDefault(require("body-parser"));
|
|
41
|
+
const overlay_1 = require("@bsv/overlay");
|
|
42
|
+
const sdk_1 = require("@bsv/sdk");
|
|
43
|
+
const knex_1 = __importDefault(require("knex"));
|
|
44
|
+
const mongodb_1 = require("mongodb");
|
|
45
|
+
const makeUserInterface_js_1 = __importDefault(require("./makeUserInterface.js"));
|
|
46
|
+
const DiscoveryServices = __importStar(require("@bsv/overlay-discovery-services"));
|
|
47
|
+
/**
|
|
48
|
+
* In-memory migration source for Knex migrations.
|
|
49
|
+
* Allows running migrations defined in code rather than files.
|
|
50
|
+
*/
|
|
51
|
+
class InMemoryMigrationSource {
|
|
52
|
+
constructor(migrations) {
|
|
53
|
+
this.migrations = migrations;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Gets the list of migrations.
|
|
57
|
+
* @param loadExtensions - Array of file extensions to filter by (not used here)
|
|
58
|
+
* @returns Promise resolving to the array of migrations
|
|
59
|
+
*/
|
|
60
|
+
async getMigrations(loadExtensions) {
|
|
61
|
+
return this.migrations;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets the name of a migration.
|
|
65
|
+
* @param migration - The migration object
|
|
66
|
+
* @returns The name of the migration
|
|
67
|
+
*/
|
|
68
|
+
getMigrationName(migration) {
|
|
69
|
+
return migration.name || `Migration at index ${this.migrations.indexOf(migration)}`;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Gets the migration object.
|
|
73
|
+
* @param migration - The migration object
|
|
74
|
+
* @returns Promise resolving to the migration object
|
|
75
|
+
*/
|
|
76
|
+
getMigration(migration) {
|
|
77
|
+
return Promise.resolve(migration);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* OverlayExpress class provides an Express-based server for hosting Overlay Services.
|
|
82
|
+
* It allows configuration of various components like databases, topic managers, and lookup services.
|
|
83
|
+
* It encapsulates an Express application and provides methods to start the server.
|
|
84
|
+
*/
|
|
85
|
+
class OverlayExpress {
|
|
86
|
+
/**
|
|
87
|
+
* Constructs an instance of OverlayExpress.
|
|
88
|
+
* @param name - The name of the service
|
|
89
|
+
* @param privateKey - Private key used for signing advertisements
|
|
90
|
+
* @param hostingURL - The public URL where this service is hosted
|
|
91
|
+
*/
|
|
92
|
+
constructor(name, privateKey, hostingURL) {
|
|
93
|
+
this.name = name;
|
|
94
|
+
this.privateKey = privateKey;
|
|
95
|
+
this.hostingURL = hostingURL;
|
|
96
|
+
// Server port
|
|
97
|
+
this.port = 3000;
|
|
98
|
+
// Logger (defaults to console)
|
|
99
|
+
this.logger = console;
|
|
100
|
+
// Knex (SQL) database
|
|
101
|
+
this.knex = undefined;
|
|
102
|
+
// Knex migrations to run
|
|
103
|
+
this.migrationsToRun = [];
|
|
104
|
+
// MongoDB database
|
|
105
|
+
this.mongoDb = undefined;
|
|
106
|
+
// Network ('main' or 'test')
|
|
107
|
+
this.network = 'main';
|
|
108
|
+
// Chain tracker
|
|
109
|
+
this.chainTracker = new sdk_1.WhatsOnChain(this.network);
|
|
110
|
+
// The Overlay Engine
|
|
111
|
+
this.engine = undefined;
|
|
112
|
+
// Configured Topic Managers
|
|
113
|
+
this.managers = {};
|
|
114
|
+
// Configured Lookup Services
|
|
115
|
+
this.services = {};
|
|
116
|
+
// Enable GASP Sync
|
|
117
|
+
this.enableGASPSync = true;
|
|
118
|
+
// ARC API Key
|
|
119
|
+
this.arcApiKey = undefined;
|
|
120
|
+
this.app = (0, express_1.default)();
|
|
121
|
+
this.logger.log(`${name} constructed`);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Configures the port on which the server will listen.
|
|
125
|
+
* @param port - The port number
|
|
126
|
+
*/
|
|
127
|
+
configurePort(port) {
|
|
128
|
+
this.port = port;
|
|
129
|
+
this.logger.log(`Server port set to ${port}`);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Configures the logger to be used by the server.
|
|
133
|
+
* @param logger - A logger object (e.g., console)
|
|
134
|
+
*/
|
|
135
|
+
configureLogger(logger) {
|
|
136
|
+
this.logger = logger;
|
|
137
|
+
this.logger.log('Logger has been configured.');
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Configures the BSV Blockchain network to be used ('main' or 'test').
|
|
141
|
+
* @param network - The network ('main' or 'test')
|
|
142
|
+
*/
|
|
143
|
+
configureNetwork(network) {
|
|
144
|
+
this.network = network;
|
|
145
|
+
this.chainTracker = new sdk_1.WhatsOnChain(this.network);
|
|
146
|
+
this.logger.log(`Network set to ${network}`);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Configures the ChainTracker to be used.
|
|
150
|
+
* @param chainTracker - An instance of ChainTracker
|
|
151
|
+
*/
|
|
152
|
+
configureChainTracker(chainTracker = new sdk_1.WhatsOnChain(this.network)) {
|
|
153
|
+
this.chainTracker = chainTracker;
|
|
154
|
+
this.logger.log('ChainTracker has been configured.');
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Configures the ARC API key.
|
|
158
|
+
* @param apiKey - The ARC API key
|
|
159
|
+
*/
|
|
160
|
+
configureArcApiKey(apiKey) {
|
|
161
|
+
this.arcApiKey = apiKey;
|
|
162
|
+
this.logger.log('ARC API key has been configured.');
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Enables or disables GASP synchronization.
|
|
166
|
+
* @param enable - true to enable, false to disable
|
|
167
|
+
*/
|
|
168
|
+
configureEnableGASPSync(enable) {
|
|
169
|
+
this.enableGASPSync = enable;
|
|
170
|
+
this.logger.log(`GASP synchronization ${enable ? 'enabled' : 'disabled'}.`);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Configures the Knex (SQL) database connection.
|
|
174
|
+
* @param config - Knex configuration object, or MySQL connection string (e.g. mysql://overlayAdmin:overlay123@mysql:3306/overlay).
|
|
175
|
+
*/
|
|
176
|
+
async configureKnex(config) {
|
|
177
|
+
if (typeof config === 'string') {
|
|
178
|
+
config = {
|
|
179
|
+
client: 'mysql2',
|
|
180
|
+
connection: config
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
this.knex = (0, knex_1.default)(config);
|
|
184
|
+
this.logger.log('Knex successfully configured.');
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Configures the MongoDB database connection.
|
|
188
|
+
* @param connectionString - MongoDB connection string
|
|
189
|
+
*/
|
|
190
|
+
async configureMongo(connectionString) {
|
|
191
|
+
const mongoClient = new mongodb_1.MongoClient(connectionString);
|
|
192
|
+
await mongoClient.connect();
|
|
193
|
+
const db = mongoClient.db(`${this.name}_lookup_services`);
|
|
194
|
+
this.mongoDb = db;
|
|
195
|
+
this.logger.log('MongoDB successfully configured and connected.');
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Configures a Topic Manager.
|
|
199
|
+
* @param name - The name of the Topic Manager
|
|
200
|
+
* @param manager - An instance of TopicManager
|
|
201
|
+
*/
|
|
202
|
+
configureTopicManager(name, manager) {
|
|
203
|
+
this.managers[name] = manager;
|
|
204
|
+
this.logger.log(`Configured topic manager ${name}`);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Configures a Lookup Service.
|
|
208
|
+
* @param name - The name of the Lookup Service
|
|
209
|
+
* @param service - An instance of LookupService
|
|
210
|
+
*/
|
|
211
|
+
configureLookupService(name, service) {
|
|
212
|
+
this.services[name] = service;
|
|
213
|
+
this.logger.log(`Configured lookup service ${name}`);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Configures a Lookup Service using Knex (SQL) database.
|
|
217
|
+
* @param name - The name of the Lookup Service
|
|
218
|
+
* @param serviceFactory - A factory function that creates a LookupService instance using Knex
|
|
219
|
+
*/
|
|
220
|
+
configureLookupServiceWithKnex(name, serviceFactory) {
|
|
221
|
+
this.ensureKnex();
|
|
222
|
+
const factoryResult = serviceFactory(this.knex);
|
|
223
|
+
this.services[name] = factoryResult.service;
|
|
224
|
+
this.migrationsToRun.push(...factoryResult.migrations);
|
|
225
|
+
this.logger.log(`Configured lookup service ${name} with Knex`);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Configures a Lookup Service using MongoDB.
|
|
229
|
+
* @param name - The name of the Lookup Service
|
|
230
|
+
* @param serviceFactory - A factory function that creates a LookupService instance using MongoDB
|
|
231
|
+
*/
|
|
232
|
+
configureLookupServiceWithMongo(name, serviceFactory) {
|
|
233
|
+
this.ensureMongo();
|
|
234
|
+
this.services[name] = serviceFactory(this.mongoDb);
|
|
235
|
+
this.logger.log(`Configured lookup service ${name} with MongoDB`);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Configures the Overlay Engine.
|
|
239
|
+
* @param autoConfigureShipSlap - Whether to auto-configure SHIP and SLAP services (default: true)
|
|
240
|
+
*/
|
|
241
|
+
async configureEngine(autoConfigureShipSlap = true) {
|
|
242
|
+
this.ensureKnex();
|
|
243
|
+
if (autoConfigureShipSlap) {
|
|
244
|
+
// Auto-configure SHIP and SLAP services
|
|
245
|
+
this.configureTopicManager('tm_ship', new DiscoveryServices.SHIPTopicManager());
|
|
246
|
+
this.configureTopicManager('tm_slap', new DiscoveryServices.SLAPTopicManager());
|
|
247
|
+
this.configureLookupServiceWithMongo('ls_ship', (db) => new DiscoveryServices.SHIPLookupService(new DiscoveryServices.SHIPStorage(db)));
|
|
248
|
+
this.configureLookupServiceWithMongo('ls_slap', (db) => new DiscoveryServices.SLAPLookupService(new DiscoveryServices.SLAPStorage(db)));
|
|
249
|
+
}
|
|
250
|
+
// Sync configuration
|
|
251
|
+
let syncConfig = {};
|
|
252
|
+
if (!this.enableGASPSync) {
|
|
253
|
+
for (const manager of Object.keys(this.managers)) {
|
|
254
|
+
syncConfig[manager] = false;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const storage = new overlay_1.KnexStorage(this.knex);
|
|
258
|
+
// Include the KnexStorage migrations
|
|
259
|
+
this.migrationsToRun = [...overlay_1.KnexStorageMigrations.default, ...this.migrationsToRun];
|
|
260
|
+
this.engine = new overlay_1.Engine(this.managers, this.services, storage, this.chainTracker, this.hostingURL, undefined, undefined, this.arcApiKey ? new sdk_1.ARC('https://arc.taal.com', {
|
|
261
|
+
apiKey: this.arcApiKey
|
|
262
|
+
}) : undefined, new DiscoveryServices.LegacyNinjaAdvertiser(this.privateKey, 'https://dojo.babbage.systems', this.hostingURL), syncConfig);
|
|
263
|
+
this.logger.log('Engine has been configured.');
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Ensures that Knex is configured.
|
|
267
|
+
* @throws Error if Knex is not configured
|
|
268
|
+
*/
|
|
269
|
+
ensureKnex() {
|
|
270
|
+
if (typeof this.knex === 'undefined') {
|
|
271
|
+
throw new Error('You\'ll need to configure your SQL database with the .configureKnex() method first!');
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Ensures that MongoDB is configured.
|
|
276
|
+
* @throws Error if MongoDB is not configured
|
|
277
|
+
*/
|
|
278
|
+
ensureMongo() {
|
|
279
|
+
if (typeof this.mongoDb === 'undefined') {
|
|
280
|
+
throw new Error('You\'ll need to configure your MongoDB connection with the .configureMongo() method first!');
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Ensures that the Overlay Engine is configured.
|
|
285
|
+
* @throws Error if the Engine is not configured
|
|
286
|
+
*/
|
|
287
|
+
ensureEngine() {
|
|
288
|
+
if (typeof this.engine === 'undefined') {
|
|
289
|
+
throw new Error('You\'ll need to configure your Overlay Services engine with the .configureEngine() method first!');
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Starts the Express server.
|
|
294
|
+
* Sets up routes and begins listening on the configured port.
|
|
295
|
+
*/
|
|
296
|
+
async start() {
|
|
297
|
+
this.ensureEngine();
|
|
298
|
+
this.ensureKnex();
|
|
299
|
+
const engine = this.engine;
|
|
300
|
+
const knex = this.knex;
|
|
301
|
+
this.app.use(body_parser_1.default.json({ limit: '1gb', type: 'application/json' }));
|
|
302
|
+
this.app.use(body_parser_1.default.raw({ limit: '1gb', type: 'application/octet-stream' }));
|
|
303
|
+
// Enable CORS
|
|
304
|
+
this.app.use((req, res, next) => {
|
|
305
|
+
res.header('Access-Control-Allow-Origin', '*');
|
|
306
|
+
res.header('Access-Control-Allow-Headers', '*');
|
|
307
|
+
res.header('Access-Control-Allow-Methods', '*');
|
|
308
|
+
res.header('Access-Control-Expose-Headers', '*');
|
|
309
|
+
res.header('Access-Control-Allow-Private-Network', 'true');
|
|
310
|
+
if (req.method === 'OPTIONS') {
|
|
311
|
+
res.sendStatus(200);
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
next();
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
// Serve a static documentation site or user interface
|
|
318
|
+
this.app.get('/', (req, res) => {
|
|
319
|
+
res.set('content-type', 'text/html');
|
|
320
|
+
res.send((0, makeUserInterface_js_1.default)());
|
|
321
|
+
});
|
|
322
|
+
// List hosted topic managers and lookup services
|
|
323
|
+
this.app.get('/listTopicManagers', (_, res) => {
|
|
324
|
+
(async () => {
|
|
325
|
+
try {
|
|
326
|
+
const result = await engine.listTopicManagers();
|
|
327
|
+
return res.status(200).json(result);
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
return res.status(400).json({
|
|
331
|
+
status: 'error',
|
|
332
|
+
message: error instanceof Error ? error.message : 'An unknown error occurred'
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
})().catch(() => {
|
|
336
|
+
// This catch is for any unforeseen errors in the async IIFE itself
|
|
337
|
+
res.status(500).json({
|
|
338
|
+
status: 'error',
|
|
339
|
+
message: 'Unexpected error'
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
this.app.get('/listLookupServiceProviders', (_, res) => {
|
|
344
|
+
(async () => {
|
|
345
|
+
try {
|
|
346
|
+
const result = await engine.listLookupServiceProviders();
|
|
347
|
+
return res.status(200).json(result);
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
return res.status(400).json({
|
|
351
|
+
status: 'error',
|
|
352
|
+
message: error instanceof Error ? error.message : 'An unknown error occurred'
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
})().catch(() => {
|
|
356
|
+
res.status(500).json({
|
|
357
|
+
status: 'error',
|
|
358
|
+
message: 'Unexpected error'
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
// Host documentation for the services
|
|
363
|
+
this.app.get('/getDocumentationForTopicManager', (req, res) => {
|
|
364
|
+
(async () => {
|
|
365
|
+
try {
|
|
366
|
+
const manager = req.query.manager;
|
|
367
|
+
const result = await engine.getDocumentationForTopicManager(manager);
|
|
368
|
+
res.setHeader('Content-Type', 'text/markdown');
|
|
369
|
+
return res.status(200).send(result);
|
|
370
|
+
}
|
|
371
|
+
catch (error) {
|
|
372
|
+
return res.status(400).json({
|
|
373
|
+
status: 'error',
|
|
374
|
+
message: error instanceof Error ? error.message : 'An unknown error occurred'
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
})().catch(() => {
|
|
378
|
+
res.status(500).json({
|
|
379
|
+
status: 'error',
|
|
380
|
+
message: 'Unexpected error'
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
this.app.get('/getDocumentationForLookupServiceProvider', (req, res) => {
|
|
385
|
+
(async () => {
|
|
386
|
+
try {
|
|
387
|
+
const lookupService = req.query.lookupService;
|
|
388
|
+
const result = await engine.getDocumentationForLookupServiceProvider(lookupService);
|
|
389
|
+
return res.status(200).json(result);
|
|
390
|
+
}
|
|
391
|
+
catch (error) {
|
|
392
|
+
return res.status(400).json({
|
|
393
|
+
status: 'error',
|
|
394
|
+
message: error instanceof Error ? error.message : 'An unknown error occurred'
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
})().catch(() => {
|
|
398
|
+
res.status(500).json({
|
|
399
|
+
status: 'error',
|
|
400
|
+
message: 'Unexpected error'
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
// Submit transactions and facilitate lookup requests
|
|
405
|
+
this.app.post('/submit', (req, res) => {
|
|
406
|
+
(async () => {
|
|
407
|
+
try {
|
|
408
|
+
// Parse out the topics and construct the tagged BEEF
|
|
409
|
+
const topicsHeader = req.headers['x-topics'];
|
|
410
|
+
if (!topicsHeader) {
|
|
411
|
+
throw new Error('Missing x-topics header');
|
|
412
|
+
}
|
|
413
|
+
const topics = JSON.parse(topicsHeader);
|
|
414
|
+
const taggedBEEF = {
|
|
415
|
+
beef: Array.from(req.body),
|
|
416
|
+
topics
|
|
417
|
+
};
|
|
418
|
+
// Using a callback function, we can just return once our steak is ready
|
|
419
|
+
// instead of having to wait for all the broadcasts to occur.
|
|
420
|
+
await engine.submit(taggedBEEF, (steak) => {
|
|
421
|
+
return res.status(200).json(steak);
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
catch (error) {
|
|
425
|
+
console.error(error);
|
|
426
|
+
return res.status(400).json({
|
|
427
|
+
status: 'error',
|
|
428
|
+
message: error instanceof Error ? error.message : 'An unknown error occurred'
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
})().catch(() => {
|
|
432
|
+
res.status(500).json({
|
|
433
|
+
status: 'error',
|
|
434
|
+
message: 'Unexpected error'
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
this.app.post('/lookup', (req, res) => {
|
|
439
|
+
(async () => {
|
|
440
|
+
try {
|
|
441
|
+
const result = await engine.lookup(req.body);
|
|
442
|
+
return res.status(200).json(result);
|
|
443
|
+
}
|
|
444
|
+
catch (error) {
|
|
445
|
+
console.error(error);
|
|
446
|
+
return res.status(400).json({
|
|
447
|
+
status: 'error',
|
|
448
|
+
message: error instanceof Error ? error.message : 'An unknown error occurred'
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
})().catch(() => {
|
|
452
|
+
res.status(500).json({
|
|
453
|
+
status: 'error',
|
|
454
|
+
message: 'Unexpected error'
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
if (this.arcApiKey) {
|
|
459
|
+
// Route for ARC ingest
|
|
460
|
+
this.app.post('/arc-ingest', (req, res) => {
|
|
461
|
+
(async () => {
|
|
462
|
+
try {
|
|
463
|
+
const { txid, merklePath: merklePathHex, blockHeight } = req.body;
|
|
464
|
+
const merklePath = sdk_1.MerklePath.fromHex(merklePathHex);
|
|
465
|
+
await engine.handleNewMerkleProof(txid, merklePath, blockHeight);
|
|
466
|
+
return res.status(200).json({ status: 'success', message: 'Transaction status updated' });
|
|
467
|
+
}
|
|
468
|
+
catch (error) {
|
|
469
|
+
console.error(error);
|
|
470
|
+
return res.status(400).json({
|
|
471
|
+
status: 'error',
|
|
472
|
+
message: error instanceof Error ? error.message : 'An unknown error occurred'
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
})().catch(() => {
|
|
476
|
+
res.status(500).json({
|
|
477
|
+
status: 'error',
|
|
478
|
+
message: 'Unexpected error'
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
this.logger.warn('Disabling ARC because no ARC API key was provided.');
|
|
485
|
+
}
|
|
486
|
+
if (this.enableGASPSync) {
|
|
487
|
+
// Routes for GASP synchronization
|
|
488
|
+
this.app.post('/requestSyncResponse', (req, res) => {
|
|
489
|
+
(async () => {
|
|
490
|
+
try {
|
|
491
|
+
const topic = req.headers['x-bsv-topic'];
|
|
492
|
+
const response = await engine.provideForeignSyncResponse(req.body, topic);
|
|
493
|
+
return res.status(200).json(response);
|
|
494
|
+
}
|
|
495
|
+
catch (error) {
|
|
496
|
+
console.error(error);
|
|
497
|
+
return res.status(400).json({
|
|
498
|
+
status: 'error',
|
|
499
|
+
message: error instanceof Error ? error.message : 'An unknown error occurred'
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
})().catch(() => {
|
|
503
|
+
res.status(500).json({
|
|
504
|
+
status: 'error',
|
|
505
|
+
message: 'Unexpected error'
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
this.app.post('/requestForeignGASPNode', (req, res) => {
|
|
510
|
+
(async () => {
|
|
511
|
+
try {
|
|
512
|
+
const { graphID, txid, outputIndex } = req.body;
|
|
513
|
+
const response = await engine.provideForeignGASPNode(graphID, txid, outputIndex);
|
|
514
|
+
return res.status(200).json(response);
|
|
515
|
+
}
|
|
516
|
+
catch (error) {
|
|
517
|
+
console.error(error);
|
|
518
|
+
return res.status(400).json({
|
|
519
|
+
status: 'error',
|
|
520
|
+
message: error instanceof Error ? error.message : 'An unknown error occurred'
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
})().catch(() => {
|
|
524
|
+
res.status(500).json({
|
|
525
|
+
status: 'error',
|
|
526
|
+
message: 'Unexpected error'
|
|
527
|
+
});
|
|
528
|
+
});
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
532
|
+
this.logger.warn('GASP sync is disabled.');
|
|
533
|
+
}
|
|
534
|
+
// Automatically handle migrations
|
|
535
|
+
const migrationSource = new InMemoryMigrationSource(this.migrationsToRun);
|
|
536
|
+
const result = await knex.migrate.latest({
|
|
537
|
+
migrationSource
|
|
538
|
+
});
|
|
539
|
+
this.logger.log('Knex migrations run', result);
|
|
540
|
+
// 404 handler for all other routes
|
|
541
|
+
this.app.use((req, res) => {
|
|
542
|
+
this.logger.log('404', req.url);
|
|
543
|
+
res.status(404).json({
|
|
544
|
+
status: 'error',
|
|
545
|
+
code: 'ERR_ROUTE_NOT_FOUND',
|
|
546
|
+
description: 'Route not found.'
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
// Start listening on the configured port
|
|
550
|
+
this.app.listen(this.port, () => {
|
|
551
|
+
this.logger.log(`${this.name} listening on local port ${this.port}`);
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
exports.default = OverlayExpress;
|
|
556
|
+
//# sourceMappingURL=OverlayExpress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OverlayExpress.js","sourceRoot":"","sources":["../../../src/OverlayExpress.ts"],"names":[],"mapp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