truffle framework combine with nodejs express framework

Created on 6 Jun 2017  Â·  3Comments  Â·  Source: trufflesuite/truffle

hi,all:
How truffle framework combine with nodejs express framework ,then provide service like express framewok。For example,I want invoke smart contract as follow:
"
var express = require('express');
var app = express();

app.get('/a', function (req, res) {
// invoke a smart contract
res.send(result);
})

app.get('/b', function (req, res) {
// invoke b smart contract
res.send(result);
})

var server = app.listen(8081, function () {

var host = server.address().address
var port = server.address().port

console.log("http://%s:%s", host, port)

})
"
The truffle framework I using was downloaded from github。

Most helpful comment

We have the box which can be used to provide api end points to the smart-contract using express...
It invokes smart contracts from the get/post requests.. http://truffleframework.com/boxes/express-box

All 3 comments

Hi there. This would be the perfect use for a Truffle Box. See here: http://truffleframework.com/boxes/

We currently don't have a Truffle Box for Express, but please feel free to create one and submit your code to us -- we'll be happy to list it. CC @DiscRiskandBisque

I guess the question is more about how to co-exist pages rendered by express and ones served by truffle (with npm run dev)

We have the box which can be used to provide api end points to the smart-contract using express...
It invokes smart contracts from the get/post requests.. http://truffleframework.com/boxes/express-box

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tcurdt picture tcurdt  Â·  3Comments

arunmitteam picture arunmitteam  Â·  3Comments

rstormsf picture rstormsf  Â·  3Comments

JustinDrake picture JustinDrake  Â·  4Comments

ripper234 picture ripper234  Â·  4Comments