Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert Merge pull request #330 #331

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions apps/api/src/app/groups/groups.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ describe("GroupsService", () => {
}).compile()

groupsService = await module.resolve(GroupsService)
await groupsService.initialize()

invitesService = await module.resolve(InvitesService)

const { id } = await groupsService.createGroup(
Expand Down Expand Up @@ -725,17 +723,4 @@ describe("GroupsService", () => {
await expect(fun).rejects.toThrow("You are not the admin")
})
})

describe("# initialize", () => {
it("Should initialize the cached groups", async () => {
const currentCachedGroups = await groupsService.getGroups()

await groupsService.initialize()

const updatedCachedGroups = await groupsService.getGroups()

expect(currentCachedGroups).toHaveLength(updatedCachedGroups.length)
expect(currentCachedGroups).toStrictEqual(updatedCachedGroups)
})
})
})
12 changes: 3 additions & 9 deletions apps/api/src/app/groups/groups.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,13 @@ export class GroupsService {
process.env.BACKEND_PRIVATE_KEY as string,
process.env.INFURA_API_KEY as string
)
}

/**
* Initialises the service, caches groups and may sync contract
* groups if required.
*/
async initialize() {
await this._cacheGroups()
this._cacheGroups()

/* istanbul ignore next */
if (process.env.NODE_ENV !== "test") {
setTimeout(async () => {
await this._syncContractGroups()
setTimeout(() => {
this._syncContractGroups()
}, 5000)
}
}
Expand Down
4 changes: 0 additions & 4 deletions apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ import { NestFactory } from "@nestjs/core"
import { SwaggerModule, DocumentBuilder } from "@nestjs/swagger"
import { ironSession } from "iron-session/express"
import { AppModule } from "./app/app.module"
import { GroupsService } from "./app/groups/groups.service"

async function bootstrap() {
const app = await NestFactory.create(AppModule)

const groupService = app.get(GroupsService)
await groupService.initialize()

app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
Expand Down
Loading