Express-Endpoint Demo

node v4.9.1
version: 2.0.0
endpointsharetweet
var tonicExpress = require("@runkit/runkit/express-endpoint/1.0.0") // Just provide the exports object to the tonicExpress helper var app = tonicExpress(module.exports) var bodyParser = require('body-parser'); app.use(bodyParser.urlencoded({ extended: false })); app.get("/", (req, res) => res.send("Hey!")) app.get("/:name", (req, res) => { res.send(`Hello ${req.params.name}!`) }) app.post("/echo-form", (req, res) => { var formData = Object.keys(req.body).map( k => `${k}: ${req.body[k]}` ) res.type("text/plain") res.send(formData.join("\n")) })
Once you create your Express app with the tonicExpress helper, it works like any other Express app. You can use middleware, declare routes, etc.
Loading…

22 comments

  • posted 8 years ago by wrg99
    https://nodejs.org/docs/v0.10.40/api/http.html#http_class_http_serverresponse
  • posted 8 years ago by abol
    👍 Omar aljabli
  • posted 7 years ago by imhomos
    #imhomos
  • posted 7 years ago by 59c940eec9e046001256f18e
    Is `tonicExpress` a legacy name? In other words, if you had written this Notebook today, would you have named that variable `runkitExpress` instead?
  • posted 6 years ago by lookdeepu
    Thank you.
  • posted 6 years ago by pavi2410
    I'm unable to get this work https://runkit.com/pavi2410/node-js-test
  • posted 6 years ago by ngocloi
    Z
  • posted 6 years ago by ngocloi
    O
  • posted 6 years ago by 5bdf16a8044148001354017b
  • posted 6 years ago by swn
    su-wan.examples.io
  • posted 6 years ago by swn
    pos time zone
  • posted 5 years ago by shliilh
  • posted 3 years ago by tuanggo
  • posted 2 years ago by us1
    Momo…0332938366
  • posted 2 years ago by mikypearl
    Massive
  • posted 2 years ago by shahidaleem
    Very good and very good
  • posted 9 months ago by brute-coder
    men see api , men happy
  • posted 7 months ago by 65ed7cca80d6d4000875ca0a
    Addacomment
  • posted 4 months ago by cantap969
    Ok
  • posted 4 months ago by cantap969
    Bb
  • posted a month ago by saingmyatkyaw
    Good my try in upgrading.
  • posted 17 days ago by 66bd3565ce278a00083db6cf
    endpoint example cash back guarantie the with the node provided jS did no conform with the cross reference like the eula with creditnote and the resulting algorithms will about a form from the node to mount the open bill your runkit service welcome with envelope to provide the cash back the demo hang not only by the test kit iso 2009:2015 about unaesthetic images on cigarettes ... the runkit can choose about versions for the service with sodexho and a letter by a list of customer or giftcard were recap function verify your given and las but not least with a prepaid card .we tryd by giftcard and there was no echo from chargement and closed supermarket chains

sign in to comment