29 lines
846 B
TypeScript
29 lines
846 B
TypeScript
|
|
import { Hono } from 'hono';
|
||
|
|
import { createPrekeyRoutes } from './routes.js';
|
||
|
|
import { MemoryPrekeyStore } from './memory-store.js';
|
||
|
|
import type { PrekeyStore } from './store.js';
|
||
|
|
|
||
|
|
export { createPrekeyRoutes } from './routes.js';
|
||
|
|
export { MemoryPrekeyStore } from './memory-store.js';
|
||
|
|
export type { PrekeyStore } from './store.js';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create a standalone Shade Prekey Server.
|
||
|
|
*
|
||
|
|
* Can be used standalone (Docker) or embedded in another Hono app.
|
||
|
|
*
|
||
|
|
* Standalone:
|
||
|
|
* const server = createPrekeyServer();
|
||
|
|
* export default { port: 3900, fetch: server.fetch };
|
||
|
|
*
|
||
|
|
* Embedded:
|
||
|
|
* const app = new Hono();
|
||
|
|
* app.route('/shade', createPrekeyServer());
|
||
|
|
*/
|
||
|
|
export function createPrekeyServer(options?: {
|
||
|
|
store?: PrekeyStore;
|
||
|
|
}): Hono {
|
||
|
|
const store = options?.store ?? new MemoryPrekeyStore();
|
||
|
|
return createPrekeyRoutes(store);
|
||
|
|
}
|