Skip to content

Instantly share code, notes, and snippets.

@blugavere
Last active April 5, 2017 23:09
Show Gist options
  • Save blugavere/d2b7e18e3ef04e9066fdb5d74dce04f4 to your computer and use it in GitHub Desktop.
Save blugavere/d2b7e18e3ef04e9066fdb5d74dce04f4 to your computer and use it in GitHub Desktop.
// app.js
'use strict';
// initialize an express app
const express = require('express');
const mongoose = require('mongoose');
const app = express();
// create a mongoose schema
const Cat = mongoose.model('Cat', { name: { type: String, required: true } });
// set default port
const port = process.env.PORT || 3000;
// create some fake data
const kitty = new Cat({ name: 'Zildjian'});
// expose an edpoint returning that data
app.get('/data', (req, res) => res.send(kitty));
app.listen(port, () => console.log(`Server listening on port: ${port}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment