mjrdnk / express-simple-mvc

Simple starter, bare bone structure based on ExpressJS. Helps easily creating controllers for routes. Provides Flightplan file for simple deployment strategy.
MIT License
12 stars 3 forks source link

added a nexmo.js to the controllers folder #8

Closed abdullateef97 closed 6 years ago

abdullateef97 commented 6 years ago

added a nexmo module to controller, it allows u send sms using the nexmo platform

abdullateef97 commented 6 years ago

@mjrdnk where do i add the usage

mjrdnk commented 6 years ago

For usage write a snippet for server.js and route for this controller. So only in README file we need something like this:

Examples:

Example: nexmo - sms service To write your custom controllers write your functions in the file and export the module:

here goes controller for nexmo

so the controller could be reused in router file nexmo.route.js, like this (please check other helloWorld route for implementation):

here goes route for nexmo

In order to use it in your app you have to declare it in the server.js, like this:

...
let API_BASE = config.API_BASE;
let helloWorld = require('./routes/helloWorld.js');
let nexmo = require('./routes/nexmo.route.js');

app.use(function(req, res, next) {
...

...

}));

app.use(API_BASE, helloWorld);
app.use(API_BASE, nexmo);

app.listen(port, function() {
...

After that, your new nexmo route will be available in the REST call.

If you have further questions, please ask.

abdullateef97 commented 6 years ago

everything shd be in the readme file

mjrdnk commented 6 years ago

Yes, this use case (nexmo) is so specific that it's place should be in the README examples section. However it would be the best to have some more generic example, but I will accept it anyway.

abdullateef97 commented 6 years ago

@mjrdnk i believe my new commit should meet your specs

mjrdnk commented 6 years ago

Just saw that markup is broken after merging. Please fix.

abdullateef97 commented 6 years ago

can u specify what part

mjrdnk commented 6 years ago

I fixed it already. Thanks for your contribution 😊