Last active
May 18, 2019 16:05
-
-
Save fakenickels/bbc8c508c224ecf1d206b0e5ff77678c to your computer and use it in GitHub Desktop.
Node.REACT: wait that's illegal
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
const Worker = ({ databaseURL, store }) => { | |
return ( | |
<> | |
<Job name='chargeUsers' run={() => chargeUsers()} store={store}> | |
<SyncedCron at='every day at 8am' /> | |
</Job> | |
<Job name='sendEmail' run={sendgridSendEmail} store={store} /> | |
</> | |
); | |
}; | |
const GraphQL = (props) => ( | |
<GraphQLSchema {...props}> | |
<GraphQLQuery> | |
<GraphQLObject name='User' resolve={(root, args, ctx) => ctx(props.databaseURL).currentUser}> | |
<GraphQLNonNullString name='name' resolve={user => user.name} /> | |
</GraphQLObject> | |
<GraphQLString name='hello' resolve={() => "hello"} /> | |
</GraphQLQuery> | |
</GraphQLSchema> | |
); | |
const App = ({ port }) => { | |
return ( | |
<Koa port={port}> | |
<Route post get path='/'> | |
<GraphQL /> | |
</Route> | |
<Route get path='/ping'> | |
{(req, res) => res.send("pong")} | |
</Route> | |
</Koa> | |
); | |
}; | |
const store = new Bull({}); | |
Node.run( | |
<App port={process.env.PORT} databaseURL={process.env.DATABASE_URL} store /> | |
); | |
Node.run(<Worker databaseURL={process.env.DATABASE_URL} store />); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment