-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1744 from Inist-CNRS/feat/precomputed-process
feat: process precomputed data
- Loading branch information
Showing
17 changed files
with
583 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Koa from 'koa'; | ||
import route from 'koa-route'; | ||
import bodyParser from 'koa-bodyparser'; | ||
|
||
import getLogger from '../services/logger'; | ||
import { getComputedFromWebservice } from '../services/precomputed/precomputed'; | ||
|
||
export const getComputedWebserviceData = async ctx => { | ||
const { precomputedId, tenant, jobId } = ctx.request.query; | ||
const { identifier, generator, state } = ctx.request.body; | ||
const logger = getLogger(ctx.tenant); | ||
logger.info(`Precompute webhook call for ${tenant}`); | ||
logger.info('Body', ctx.request.body); | ||
|
||
if (!state == 'ready') { | ||
return; | ||
} | ||
|
||
const callId = JSON.stringify([{ id: generator, value: identifier }]); | ||
|
||
await getComputedFromWebservice(ctx, tenant, precomputedId, callId, jobId); | ||
|
||
ctx.body = 'webhook ok'; | ||
ctx.status = 200; | ||
}; | ||
|
||
const app = new Koa(); | ||
app.use(bodyParser()); | ||
app.use(route.post('/compute_webservice/', getComputedWebserviceData)); | ||
|
||
export default app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.