Created
December 27, 2018 10:18
-
-
Save killmenot/7f7b7171683ef397dc9a2fcbec4d2b32 to your computer and use it in GitHub Desktop.
Example of using json-server with EwdRedis adapter with Qewd microservices startup
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 low = require('lowdb') | |
const jsonServer = require('json-server') | |
const config = require('./startup_config.json'); | |
let app; | |
let bodyParser; | |
config.addMiddleware = function(bp, express, q) { | |
bodyParser = bp; | |
app = express; | |
}; | |
function onStarted() { | |
const documentName = 'temp' | |
const adapterOptions = {} | |
const adapter = new EwdRedis(documentName, adapterOptions) | |
const db = low(adapter) | |
// TODO: add initial state if needed | |
db.setState({ | |
posts: [], | |
comments: [] | |
}) | |
const router = jsonServer.router(db) | |
const middlewares = jsonServer.defaults() | |
app.use('/api', router); | |
} | |
module.exports = { | |
config: config, | |
routes: [], | |
onStarted: onStarted | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
L20-23 json data should be set outside this export function?