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

SOF-1670 Expose Endpoint To Reload Rundown #88

Merged
merged 10 commits into from
Nov 3, 2023
22 changes: 16 additions & 6 deletions src/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,28 @@ export class Connector {
}

private setupReloadDataKoaEndpoint(): void {
this.koaRouter.get('/reloadData/:rundownName', async (ctx, next): Promise<void> => {
const RUNDOWN_EXTERNAL_ID_SUFFIX = '_1'
const KOA_PORT: number = 3007
const RUNDOWN_EXTERNAL_ID_SUFFIX: string = '_1'

this.koaRouter.post('/reloadData/:rundownName', async (context, next): Promise<void> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not following REST standards (maybe that is fine).
If we want this URL to follow REST standards, it should be changed to do so.

Personally, I would prefer it, but I can see arguments for not doing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point, and on Sofie Server i'd say it makes a lot of sense. Here, however, i might counter argue that because of the setup where we both actually work on playlists and rundowns to do this operation, it's difficult to just use e.g. rundowns/reloadData/:rundownName since it is used for both playlists and rundowns.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On another note, this is tied to our implementation of Sofie Server alone, so i will name it to fit the standard it follows!

const rundownName: string = context.params.rundownName
if (!this.iNewsFTPHandler.iNewsWatcher) {
context.status = 503
context.response.body = 'Error: iNewsWatcher is undefined'
return
}
this.iNewsFTPHandler.iNewsWatcher?.ResyncRundown(ctx.params.rundownName + RUNDOWN_EXTERNAL_ID_SUFFIX)

await next()
try {
context.response.body = `Attempting to reload rundown with name ${rundownName}`
await this.iNewsFTPHandler.iNewsWatcher.ResyncRundown( rundownName + RUNDOWN_EXTERNAL_ID_SUFFIX)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you running lint?
A lot of your PRs (not just this one) has small syntax 'issues'. Here it is an extra space before rundownName.
In your PR for SofieServer for this it appears random whether your imports have spaces or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never had this issue before with linting, i will be sure to check and do it.

await next()
} catch (error) {
context.status = 500
context.response.body = `Error: ${error}`
}
})

this.koaApp.use(this.koaRouter.routes()).use(this.koaRouter.allowedMethods())

this.koaApp.listen(3007, () => {})
this.koaApp.listen(KOA_PORT, () => {})
}
}
Loading