Required changes for Express.js app.js file
So currently to run express.js project we would be runningnode app.js
For migration obviously, we won’t be able to run two servers in parallel. So I am adding demo app.js file here so that we can understand how to export our express object which we are using in current Express.js project. This just includes “hello-word” for understanding. We just need to try and keep our Express.js project as it is so that we can migrate easily.
const express = require("express"); module.exports = function(config) { var app = express(); app.get("/hello-world", (req, res) => res.send("Hello World!")); return app; };Ok that’s the only thing we need to change in our app.js file.

Final step to “Migrate Express.js to sails.js”
http.js fileconst express = require("express"); const appJs = require("../../expressjs/app"); module.exports.http = { middleware: { order: [ "expressHook" ], expressHook: (function() { const appWrapper = express(); const appJsMigrateInstance = appJs(); appWrapper.use(appJsMigrateInstance); return appWrapper; })() } };Basically here we are extending express HTTP middleware and asking it to use our express object exported in app.js The only key part is appWrapper.use(appJsMigrateInstance); this asks our sails.js project to use all the defined routes in the expressjs/app.js file. With this code priority of the routes will be given to the expressjs/app.js file. So if any route not found in our app.js then n then that route will be served by our sails.js project. All the cors, port and session settings will be applied to the sails.js. So we need to take care of those as per our project requirement. Feel free to comment below if you have any doubt/questions. And finally, as always GitHub code is ready for you. Happy sailsjsing