Last active
March 18, 2016 14:31
-
-
Save thosakwe/280e808bcc2175b273f1 to your computer and use it in GitHub Desktop.
TypeError: Cannot read property 'service' of undefined
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
import Feathers from 'feathers'; | |
// ... | |
let app = Feathers(); | |
app | |
.use(compress()) | |
.options('*', cors()) | |
.use(cors()) | |
.use(BodyParser.json()) | |
.use(BodyParser.urlencoded({extended: true})) | |
.configure(Hooks()) | |
.configure(Rest()) | |
.configure(SocketIO()) | |
.configure(Authentication({})); | |
app.use('/users', MongooseService({ | |
Model: Models.User | |
})); | |
const Users = app.service('users'); | |
Users.before({ | |
create: [AppHooks.Users.create(), AuthenticationHooks.hashPassword()], | |
find: [AuthenticationHooks.verifyToken(), AuthenticationHooks.populateUser()], | |
get: [AuthenticationHooks.verifyToken(), AuthenticationHooks.populateUser()], | |
update: [AuthenticationHooks.hashPassword(), AuthenticationHooks.verifyToken(), AuthenticationHooks.populateUser(), AuthenticationHooks.requireAuth(), AppHooks.Users.usersCanOnlyModifyThemselves(Users)], | |
patch: [AuthenticationHooks.hashPassword(), AuthenticationHooks.verifyToken(), AuthenticationHooks.populateUser(), AuthenticationHooks.requireAuth(), AppHooks.Users.usersCanOnlyModifyThemselves(Users)], | |
remove: [AuthenticationHooks.verifyToken(), AuthenticationHooks.populateUser(), AuthenticationHooks.requireAuth(), AppHooks.Users.usersCanOnlyModifyThemselves(Users)] | |
}).after({ | |
all: [MongooseService.hooks.toObject(), AppHooks.Users.hidePassword] | |
}); | |
// ... | |
export default app; |
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
#!/usr/bin/env node | |
// ../build/app is my Babel output dir | |
var app = require('../build/app'); | |
var port = normalizePort(process.env.PORT || '3000'); | |
app.listen(port); | |
console.log(`Listening on ${port}`); | |
function normalizePort(val) { | |
var port = parseInt(val, 10); | |
if (isNaN(port)) { | |
// named pipe | |
return val; | |
} | |
if (port >= 0) { | |
// port number | |
return port; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment