-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/VL-280 (#8) - Implemented update & remove event stream
* Implemented update & remove event stream --------- Co-authored-by: CCTuduran <140727607+CCTuduran@users.noreply.github.com> Co-authored-by: dennycarusonttdata <denny.caruso@nttdata.com> Co-authored-by: Alexandru Daniel Iova <alexandrudaniel.iova@emeal.nttdata.com>
- Loading branch information
1 parent
f7cbdfb
commit 144a88f
Showing
12 changed files
with
495 additions
and
74 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,40 @@ | ||
import { flow, pipe } from 'fp-ts/function'; | ||
import * as Apply from 'fp-ts/Apply'; | ||
import * as E from 'fp-ts/Either'; | ||
import * as t from 'io-ts'; | ||
import * as TE from 'fp-ts/TaskEither'; | ||
import * as T from 'fp-ts/Task'; | ||
import express from 'express'; | ||
import { traceWithValue } from 'fp-ts-std/Debug'; | ||
import { updateStreamRecordReturningOnlyTheOneUpdatedStream } from '../../../useCases/PersistRecord'; | ||
import { Handler, toExpressHandler } from '../Handler'; | ||
import { SystemEnv } from '../../../useCases/SystemEnv'; | ||
import * as Problem from '../Problem'; | ||
import { makeUpdateStreamRecord } from '../../../domain/UpdateStreamRecord'; | ||
import { StreamCreationRequest } from '../../../generated/streams/StreamCreationRequest'; | ||
|
||
const handler = | ||
(env: SystemEnv): Handler => | ||
(req, res) => | ||
pipe( | ||
Apply.sequenceS(E.Apply)({ | ||
apiKey: t.string.decode(req.headers['x-api-key']), | ||
body: StreamCreationRequest.decode(req.body), | ||
streamId: t.string.decode(req.params.streamId), | ||
}), | ||
E.map(flow(makeUpdateStreamRecord(env), traceWithValue("aaa: "), updateStreamRecordReturningOnlyTheOneUpdatedStream(env))), | ||
E.map( | ||
TE.fold( | ||
(_) => T.of(res.status(404).send(Problem.fromNumber(404))), | ||
({ output }) => T.of(res.status(output.statusCode).send(output.returned)) | ||
) | ||
) | ||
); | ||
|
||
export const makeUpdateEventStreamRouter = (env: SystemEnv): express.Router => { | ||
const router = express.Router(); | ||
|
||
router.put('/delivery-progresses/streams/:streamId', toExpressHandler(handler(env))); | ||
|
||
return router; | ||
}; |
Oops, something went wrong.