Building a simple API in Node.js using Vaxic

Ethan Davis
Dec 5, 2017 · 1 min read
npm install vaxic

const V = require('vaxic')
const app = new V()
app.add('GET', '/api/names', (req, res) => {
res.writeHead(200, {'Content-Type': 'application/json'})
res.end(JSON.stringify(['Ethan', 'James', 'Jason', 'Justin']))
app.add('POST', '/api/log', (req, res) => {
console.log('Received message: ' + req.body.toString())
res.writeHead(200, {'Content-Type': 'application/json'})
'success': 'Logged message.'

app.listen(8080, 'localhost', () => {
console.log('Listening. ;)')

Ethan Davis

Written by

17. High school student.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade