Closed jonwrona closed 5 years ago
index.js
const express = require('express');
const bodyParser = require('body-parser');
const { promisify } = require('util');
const initializeDatabase = require('./database');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
const startServer = async () => {
await initializeDatabase(app);
const port = process.env.PORT || 3000;
await promisify(app.listen).bind(app)(port);
console.log(`Listening on port ${port}`);
};
startServer();
database.js
const Sequelize = require('sequelize');
const epilogue = require('epilogue');
const database = new Sequelize({
dialect: 'sqlite',
storage: './test.sqlite',
});
const Whitelist = database.define('whitelists', {
blueGroupName: Sequelize.STRING,
});
const initializeDatabase = async (app) => {
epilogue.initialize({ app, sequelize: database });
epilogue.resource({
model: Whitelist,
// endpoints: [ `/whitelists`, `/whitelists/:id` ],
});
await database.sync();
};
module.exports = initializeDatabase;
Here is the package.json
if dependency versions could be the issue:
{
"name": "whitelister-api",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"body-parser": "^1.19.0",
"epilogue": "^0.7.1",
"express": "^4.17.1",
"sequelize": "^5.9.4",
"sqlite": "^3.0.3",
"sqlite3": "^4.0.9",
"util": "^0.12.1"
}
}
I just started seeing this today as well when we upgraded to using sequelize v5
I had the same issue, try to use this: https://github.com/tommybananas/finale
@tymoteuszKlocek I grabbed that and it solved my issues! Thanks.
Trying to get a very simple setup of epilogue working with an sqlite database. Apparently headers are being set after they are sent to the client. This happens on any attempt to use one of the epilogue routes.
For a
create
call the error points tores.header('Location', location);
, which is on line 46 of thecreate.js
Controller.I am using Node v12.4.0.
Here is the entire error:
I can post my code as well if necessary, the server is very small.