initialize server action states

This commit is contained in:
mbecker20
2022-04-13 05:46:30 -07:00
parent f801e0f0d1
commit 6eeed044ec
2 changed files with 13 additions and 9 deletions

View File

@@ -13,6 +13,7 @@ async function addServer(app: FastifyInstance, user: User, { server }: { server:
}
server.owners = [user.username];
const created = await app.servers.create(server);
app.serverActionStates.add(server._id!);
addServerUpdate(
app,
created._id!,

View File

@@ -128,15 +128,6 @@ const actionStates = fp((app: FastifyInstance, _: {}, done: () => void) => {
},
});
app.builds.find({}, { _id: true }).then((builds) => {
builds.forEach((build) => app.buildActionStates.add(build._id!));
});
app.deployments.find({}, { _id: true }).then((deployments) => {
deployments.forEach((deployment) =>
app.deployActionStates.add(deployment._id!)
);
});
app.decorate("serverActionStates", {
getJSON: (serverID: string) => {
return serverActionStates[serverID];
@@ -171,6 +162,18 @@ const actionStates = fp((app: FastifyInstance, _: {}, done: () => void) => {
},
});
app.builds.find({}, { _id: true }).then((builds) => {
builds.forEach((build) => app.buildActionStates.add(build._id!));
});
app.deployments.find({}, { _id: true }).then((deployments) => {
deployments.forEach((deployment) =>
app.deployActionStates.add(deployment._id!)
);
});
app.servers.find({}, { _id: true }).then((servers) => {
servers.forEach((server) => app.serverActionStates.add(server._id!));
});
done();
});