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…

18 comments

  • posted 7 years ago by wrg99
    https://nodejs.org/docs/v0.10.40/api/http.html#http_class_http_serverresponse
  • posted 7 years ago by abol
    👍 Omar aljabli
  • posted 7 years ago by imhomos
    #imhomos
  • posted 6 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 5 years ago by ngocloi
    Z
  • posted 5 years ago by ngocloi
    O
  • posted 5 years ago by 5bdf16a8044148001354017b
    suwanpos@examples.com
  • posted 5 years ago by swn
    su-wan.examples.io
  • posted 5 years ago by swn
    pos time zone
  • posted 4 years ago by shliilh
    shlilh65@gmail.com
  • posted 2 years ago by tuanggo
    ngo461596@gmail.com
  • posted 2 years ago by us1
    Momo…0332938366
  • posted a year ago by mikypearl
    Massive
  • posted a year ago by shahidaleem
    Very good and very good
  • posted 2 months ago by brute-coder
    men see api , men happy
  • posted 9 days ago by 65ed7cca80d6d4000875ca0a
    Addacomment

sign in to comment