Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use epilogue with egg.js #1962

Closed
anuxs opened this issue Jan 15, 2018 · 2 comments
Closed

how to use epilogue with egg.js #1962

anuxs opened this issue Jan 15, 2018 · 2 comments

Comments

@anuxs
Copy link

anuxs commented Jan 15, 2018

epilogue is Create flexible REST endpoints and controllers from Sequelize models in your Express or Restify app.
https://github.com/dchester/epilogue

With Express , I can do like this

// Initialize server
  const express = require('express'),
      bodyParser = require('body-parser');
  let app=express();
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({extended:false}));
  let server=http.createServer(app);

  // Initialize epilogue
  epilogue.initialize({
    app: app,
    sequelize: database
  });

  // Create REST resource
  let userResource = epilogue.resource({
    model: User,
    endpoints: ['/googles', '/googles/:id']
  });

  // Create database and listen
  database
    .sync({ force: true })
    .then(function() {
      server.listen(function() {
        let host = server.address().address,
            port = server.address().port;
        console.log('listening at http://%s:%s', host, port);
      });
    });

How to initialize epilogue and create REST resource in egg.js ?

@atian25
Copy link
Member

atian25 commented Jan 16, 2018

if epilogue had a koa middleware, then you could just import it.

dchester/epilogue#100

or maybe you had to write one.

@atian25 atian25 closed this as completed Jan 16, 2018
@anuxs
Copy link
Author

anuxs commented Jan 16, 2018

i had try what your said with koa ,and also get an error info . this issue was created by me :
dchester/epilogue#229
app[self.method] is not a function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants