MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / init

Function init

packages/typesense/src/init.ts:5–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { collectionSchema } from './utils/model';
4
5export async function init() {
6 try {
7 await client.collections().create(collectionSchema);
8 } catch (error: any) {
9 if (error.name === 'ObjectAlreadyExists' || error.httpStatus === 409) {
10 console.error({ error: JSON.stringify(error) });
11 } else {
12 if (error.message === 'connect ECONNREFUSED 127.0.0.1:8108') {
13 console.log('-----------------------');
14 console.log(
15 'Please ensure that you have a typesense server running at port 8108'
16 );
17 console.log(
18 'Step 1. Find out how to install typesense locally from their docs.'
19 );
20 console.log(
21 'Step 2. Then run the following command, choose your own data dir.'
22 );
23 console.log(
24 './typesense-server --data-dir=/MyDataDir --api-key=xyz --api-port=8108'
25 );
26 console.log('-----------------------');
27 }
28 throw error;
29 }
30 }
31 return await createSearchOnlyKey(collectionSchema.name);
32}
33
34if (require.main === module) {
35 init().then((key) => {

Callers 2

jest.setup.jsFile · 0.85
init.tsFile · 0.85

Calls 4

createSearchOnlyKeyFunction · 0.90
errorMethod · 0.65
logMethod · 0.65
createMethod · 0.45

Tested by

no test coverage detected