Skip to content

Instantly share code, notes, and snippets.

@frankzickert
Last active August 20, 2019 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankzickert/4c8f52c7efcd50edb63f2f10796071cd to your computer and use it in GitHub Desktop.
Save frankzickert/4c8f52c7efcd50edb63f2f10796071cd to your computer and use it in GitHub Desktop.
import * as React from 'react';
import {
callService,
Middleware,
mutate,
Service,
serviceWithDataLayer
} from "infrastructure-components";
import { USER_ENTRY_ID, IUserEntry } from './user-entry';
const ADDUSER_SERVICE_ID = "adduser";
export default function AddUserService () {
return <Service
id={ ADDUSER_SERVICE_ID }
path="/adduser"
method="POST">
<Middleware
callback={serviceWithDataLayer(async function (dataLayer, req, res, next) {
const parsedBody: IUserEntry = JSON.parse(req.body);
await mutate(
dataLayer.client,
dataLayer.setEntryMutation(USER_ENTRY_ID, parsedBody)
);
res.status(200).set({
"Access-Control-Allow-Origin" : "*", // Required for CORS support to work
}).send("ok");
})}/>
</Service>
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment