CoolFace
Apppublic

strong-tie/inbound-calls

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
example.js30 linesDownload Raw Back to find-my-way
1'use strict'2 3const http = require('http')4const router = require('./')({5  defaultRoute: (req, res) => {6    res.end('not found')7  }8})9 10router.on('GET', '/test', (req, res, params) => {11  res.end('{"hello":"world"}')12})13 14router.on('GET', '/:test', (req, res, params) => {15  res.end(JSON.stringify(params))16})17 18router.on('GET', '/text/hello', (req, res, params) => {19  res.end('{"winter":"is here"}')20})21 22const server = http.createServer((req, res) => {23  router.lookup(req, res)24})25 26server.listen(3000, err => {27  if (err) throw err28  console.log('Server listening on: http://localhost:3000')29})30