import 'express-async-errors' import 'reflect-metadata' import fs from 'node:fs' import path from 'node:path' import debug from 'debug' import { OAuthApp } from '@octokit/oauth-app' import { Database } from './database' import { Registry } from './registry' import { createResolvers } from './resolvers' import { createAndStartServer } from './server' import { Service } from './service' import { getConfig } from './utils' const log = debug('snowball:server') const OAUTH_CLIENT_TYPE = 'oauth-app' export const main = async (): Promise => { const { server, database, gitHub, registryConfig } = await getConfig() const app = new OAuthApp({ clientType: OAUTH_CLIENT_TYPE, clientId: gitHub.oAuth.clientId, clientSecret: gitHub.oAuth.clientSecret }) const db = new Database(database) await db.init() const registry = new Registry(registryConfig) const service = new Service( { gitHubConfig: gitHub, registryConfig }, db, app, registry ) const typeDefs = fs .readFileSync(path.join(__dirname, 'schema.gql')) .toString() const resolvers = await createResolvers(service) await createAndStartServer(server, typeDefs, resolvers, service) } main() .then(() => { log('Starting server...') }) .catch((err) => { log(err) })