Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
Express-Endpoint Demo
node v4.9.1
version:
2.0.0
endpoint
share
tweet
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…
20 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
suwanpos@examples.com
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
shlilh65@gmail.com
posted
3 years ago
by
tuanggo
ngo461596@gmail.com
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
8 months ago
by
brute-coder
men see api , men happy
posted
6 months ago
by
65ed7cca80d6d4000875ca0a
Addacomment
posted
2 months ago
by
cantap969
Ok
posted
2 months ago
by
cantap969
Bb
sign in
to comment