Last active
March 7, 2020 06:42
-
-
Save TNick/d7253113de3b683aa67a0d7e6fa4aab4 to your computer and use it in GitHub Desktop.
react-admin standalone fake server for graphql
This file contains hidden or 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 express = require('express'); | |
const cors = require('cors'); | |
const generateData = require('data-generator-retail').default; | |
const jsonGraphqlExpress = require('json-graphql-server').default; | |
const log = require('debug')('fakeServer:alone-graphql:log'); | |
log('-------------------------------------------------'); | |
log('fakeServer is starting'); | |
log('-------------------------------------------------'); | |
const PORT = 4000; | |
const app = express(); | |
const data = generateData({ serializeDate: false }); | |
log('data with %d entries generated', Object.keys(data).length); | |
app.use(cors()); | |
app.use('/graphql', jsonGraphqlExpress(data)); | |
log('-------------------------------------------------'); | |
log('fakeServer started; listening to localhost:%d', PORT); | |
log('-------------------------------------------------'); | |
app.listen(PORT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment