Last active
April 5, 2017 23:09
-
-
Save blugavere/d2b7e18e3ef04e9066fdb5d74dce04f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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