Skip to content

Instantly share code, notes, and snippets.

@thomasswilliams
Last active November 18, 2019 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasswilliams/39c3d38b4c5b0ac88f7959f6edf6ee29 to your computer and use it in GitHub Desktop.
Save thomasswilliams/39c3d38b4c5b0ac88f7959f6edf6ee29 to your computer and use it in GitHub Desktop.
Express & TypeScript Pedals API base, Nov 2019 - server.ts
// in src directory
import express from "express";
const app = express();
// route: get pedals collection
app.get("/pedals", (req, res) => {
console.log("Got pedals collection");
// hard-code JSON response
res.send({ pedals: [{ name: "Boss SY-1", id: 1 }] });
});
// port to listen on
const port = 34512;
// start Express server
app.listen(port, () => {
console.log(`Express server listening at http://localhost:${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment