-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
38 lines (31 loc) · 1011 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import 'reflect-metadata';
import { setupApp } from './app';
import config from './config';
import { UserRepository } from './db/repositories/User.repository';
import { InternalKeysStorage } from './modules/keysStorage/internalKeysStorage';
import { saveOpenApiSchema } from './openapi';
async function seedData(userRepository: UserRepository) {
return await Promise.all([
userRepository.create({ email: '[email protected]', password: 'S0m3P@ssw0rd' }),
userRepository.create({
email: '[email protected]',
password: 'S0m3P@ssw0rd2',
}),
]);
}
async function main() {
try {
const keysStorage = new InternalKeysStorage();
const userRepository = new UserRepository(keysStorage);
await seedData(userRepository);
const app = await setupApp({ keysStorage, userRepository });
if (config.isDevelopment) {
saveOpenApiSchema(app);
}
await app.listen(config.PORT, config.HOST);
} catch (err) {
console.error({ err });
process.exit(1);
}
}
main();