snowballtools-base/packages/backend/src/index.ts
prathamesh0 4d00cfb8f0 Add graphql schema (#18)
* Add graphql schema

* Remove circular references in gql schema

* Remove unnecessary todos

---------

Co-authored-by: neeraj <neeraj.rtly@gmail.com>
2024-02-01 11:37:57 +05:30

31 lines
836 B
TypeScript

import 'reflect-metadata';
import debug from 'debug';
import fs from 'fs';
import path from 'path';
import { initializeDatabase } from './database';
import { createAndStartServer } from './server';
import { createResolvers } from './resolvers';
import { getConfig } from './utils';
import { Config } from './type';
const log = debug('snowball:server');
const configFilePath = 'environments/local.toml';
export const main = async (): Promise<void> => {
// TODO: get config path using cli
const { server } = await getConfig<Config>(configFilePath);
await initializeDatabase();
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
await createAndStartServer(typeDefs, createResolvers, server);
};
main()
.then(() => {
log('Starting server...');
})
.catch((err) => {
log(err);
});