-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
29 lines (24 loc) · 794 Bytes
/
index.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
import app from './src/app';
import sequelize from './src/config/database';
import User from './src/user/User';
import bcrypt from 'bcrypt';
import TokenService from './src/auth/TokenService';
const addUsers = async (activeUserCount: number, inactiveUserCount = 0) => {
const hash = await bcrypt.hash('P4ssword', 10);
for (let i = 0; i < activeUserCount + (inactiveUserCount || 0); i += 1) {
await User.create({
username: `user${i + 1}`,
email: `user${i + 1}@mail.com`,
password: hash,
inactive: i >= activeUserCount,
});
}
};
// initializing sequalize
sequelize.sync({ force: true }).then(async () => {
await addUsers(25);
});
TokenService.scheduleCleanup();
app.listen(3000, () => {
console.log(`app is running in ${process.env.NODE_ENV}`);
});