24 lines
602 B
TypeScript
24 lines
602 B
TypeScript
|
|
import { resolveConfig, type ShadeConfig } from './config.js';
|
||
|
|
import { Shade } from './shade.js';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create and initialize a Shade instance in one call.
|
||
|
|
*
|
||
|
|
* ```ts
|
||
|
|
* const shade = await createShade({
|
||
|
|
* prekeyServer: 'https://shade.example.com',
|
||
|
|
* storage: 'sqlite:/data/shade.db',
|
||
|
|
* });
|
||
|
|
*
|
||
|
|
* await shade.send('bob@example.com', 'hello');
|
||
|
|
* ```
|
||
|
|
*
|
||
|
|
* See ShadeConfig for all options.
|
||
|
|
*/
|
||
|
|
export async function createShade(config: ShadeConfig): Promise<Shade> {
|
||
|
|
const resolved = resolveConfig(config);
|
||
|
|
const shade = new Shade(resolved);
|
||
|
|
await shade.initialize();
|
||
|
|
return shade;
|
||
|
|
}
|