sushiswap-watcher-ts/packages/v2-watcher/src/server.ts
Prathamesh Musale b1b79c844a Generate watcher for sushiswap v2 subgraph (#2)
Part of [Generate watchers for sushiswap subgraphs deployed in graph-node](https://www.notion.so/Generate-watchers-for-sushiswap-subgraphs-deployed-in-graph-node-b3f2e475373d4ab1887d9f8720bd5ae6)

Reviewed-on: #2
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-06-12 04:15:03 +00:00

44 lines
1.1 KiB
TypeScript

//
// Copyright 2021 Vulcanize, Inc.
//
import fs from 'fs';
import path from 'path';
import 'reflect-metadata';
import debug from 'debug';
import { ServerCmd } from '@cerc-io/cli';
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
import { createResolvers } from './resolvers';
import { Indexer } from './indexer';
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from './database';
const log = debug('vulcanize:server');
export const main = async (): Promise<any> => {
const serverCmd = new ServerCmd();
await serverCmd.init(Database);
const { graphWatcher } = await getGraphDbAndWatcher(
serverCmd.config.server,
serverCmd.clients.ethClient,
serverCmd.ethProvider,
serverCmd.database.baseDatabase,
ENTITY_QUERY_TYPE_MAP,
ENTITY_TO_LATEST_ENTITY_MAP
);
await serverCmd.initIndexer(Indexer, graphWatcher);
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
return serverCmd.exec(createResolvers, typeDefs);
};
main().then(() => {
log('Starting server...');
}).catch(err => {
log(err);
});