1
1
'use strict'
2
2
const express = require ( 'express' )
3
- const app = express ( )
3
+ const server = express ( )
4
4
5
5
// Get the Mongoose models used for querying the database
6
6
const { User } = require ( './models.js' )
@@ -32,7 +32,7 @@ const filterFields = async function(req, user) {
32
32
33
33
// Listen for all GET requests to /users/:id URL (where the
34
34
// ID is the ID of the user account)
35
- app . get ( '/users/:id' , ( req , res ) => {
35
+ server . get ( '/users/:id' , ( req , res ) => {
36
36
// Try to find the user by their id (_id field), using the ID
37
37
// parameter from the URL.
38
38
User . findById ( req . params . id , async ( err , user ) => {
@@ -54,7 +54,7 @@ app.get('/users/:id', (req, res) => {
54
54
} )
55
55
56
56
// Listen for all GET requests to /users
57
- app . get ( '/users' , ( req , res ) => {
57
+ server . get ( '/users' , ( req , res ) => {
58
58
// Find all of the users in the database collection (we pass in
59
59
// an empty collection as we aren't filtering the results)
60
60
User . find ( { } , async ( err , users ) => {
@@ -73,4 +73,4 @@ app.get('/users', (req, res) => {
73
73
} )
74
74
75
75
// Start the application, listening on port 3000
76
- app . listen ( 3000 )
76
+ server . listen ( 3000 )
0 commit comments