简体   繁体   中英

Client Side to Server Side Node.js

I have a node.js application and I have a public/somehting.js file that is client side and then I have a controller file controllers/something.js and models/something.js that does the DB connection.

How do I go from the public directory and access the server side information any ideas

my model/features.js

exports.getFeatureClass = function(Sequelize, sequelize) {
  sequelize.define("Feature", {
    project_id: Sequelize.INTEGER,
    title: Sequelize.STRING,
  });
};

my public/featurepane.js

var FeaturePane = function FeaturePane(scope) {
  console.log("hi");
  //how to I access Db
};

node isn't a "plug in"/CGI interpreter like PHP is, you need to actually set up a server in node and have that serve any requests and process server side JS.

There are several frameworks that does this for you, the most used one is probably express .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM