snowballtools-base/packages/backend/src/index.ts
nabarun 63969ae25a Implement payments for app deployments (#17)
Part of [Service provider auctions for web deployments](https://www.notion.so/Service-provider-auctions-for-web-deployments-104a6b22d47280dbad51d28aa3a91d75)
- Implement funtionality to pay for deployments by connecting wallet using `WalletConnect`

![image](/attachments/842e33e8-7de6-4d91-9008-1c67a259b586)

![image](/attachments/94b2fe39-f753-4e99-a8c2-bda4c0b84897)

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Reviewed-on: cerc-io/snowballtools-base#17
2024-10-28 09:46:18 +00:00

54 lines
1.3 KiB
TypeScript

import 'express-async-errors';
import 'reflect-metadata';
import debug from 'debug';
import fs from 'fs';
import path from 'path';
import { OAuthApp } from '@octokit/oauth-app';
import { Database } from './database';
import { createAndStartServer } from './server';
import { createResolvers } from './resolvers';
import { getConfig } from './utils';
import { Service } from './service';
import { Registry } from './registry';
const log = debug('snowball:server');
const OAUTH_CLIENT_TYPE = 'oauth-app';
export const main = async (): Promise<void> => {
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);
});