Closed rickysullivan closed 6 years ago
I have multiple data centres (MSSQL) which all have the same database, username, passwords and the same table name & schema.
I'm trying to use the same express instance to map different end points that correspond to each Sequalize instance.
servers.forEach(server => { let sequelizeInstance = new Sequelize(database, username, password, { ...options, host: server.address }); let Client = sequelizeInstance.define( "Client", { Client: { primaryKey: true, type: Sequelize.STRING }, DatabaseName: Sequelize.STRING }, { timestamps: false, freezeTableName: true } ); finale.initialize({ app: app, sequelize: sequelizeInstance }); finale.resource({ model: Client, pagination: false, endpoints: [`${server.site}/clients`, `${server.site}/clients/:id`], actions: ["list", "read"] }); db[server.site] = { sequelize: sequelizeInstance }; });
I've also tried setting a base in the initialize():
finale.initialize({ app: app, base: server.site, sequelize: sequelizeInstance });
app._router.stack returns:
app._router.stack
[ { path: 'nz/clients', method: 'get' }, { path: 'nz/clients/:id', method: 'get' }, { path: 'au/clients', method: 'get' }, { path: 'au/clients/:id', method: 'get' }, { path: 'ca/clients', method: 'get' }, { path: 'ca/clients/:id', method: 'get' }, { path: 'za/clients', method: 'get' }, { path: 'za/clients/:id', method: 'get' } ]
But performing a GET request to http://localhost:62946/nz/clients returns Cannot GET /nz/clients
http://localhost:62946/nz/clients
Cannot GET /nz/clients
I had no trouble using a single instance of Sequalize with finale-rest. What am I doing wrong?
I see the error of my ways:
endpoints: [`/${server.site}/clients`, `/${server.site}/clients/:id`]
The endpoints or the base needed to be prefixed with /
/
I have multiple data centres (MSSQL) which all have the same database, username, passwords and the same table name & schema.
I'm trying to use the same express instance to map different end points that correspond to each Sequalize instance.
I've also tried setting a base in the initialize():
app._router.stack
returns:But performing a GET request to
http://localhost:62946/nz/clients
returnsCannot GET /nz/clients
I had no trouble using a single instance of Sequalize with finale-rest. What am I doing wrong?