Require Nodemailer

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Require Nodemailer

horrido
The docs for integrating external JS libs are still in a bit of a mess. I'm trying to distill all of it to something very simple. So I would like to use the Nodemailer library. I've installed it:

npm install -g nodemailer

In the nodemailer directory, I've created a local.amd.json file:

{
   
"paths": {
       
"nodemailer": "src"
   
}
}

I believe I need to run:

grunt devel

But before I do that, how do I require this lib in my Amber project?

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Require Nodemailer

Herby Vojčík


Richard Eng wrote:
> The docs for integrating external JS libs are still in a bit of a
> mess. I'm trying to distill all of it to something *very simple*. So I
> would like to use the Nodemailer library. I've installed it:
>
> ||
> npm install -g nodemailer

-g ???

> In the nodemailer directory, I've created a local.amd.json file:

WRONG, WRONG, WRONG! YOU NEVER DO THAT!
There's libdir.amd.json for that.

Read the "Lego analogy" amber wiki article and github/herby/amd-config-builder README.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Require Nodemailer

horrido
I think I'm on the right track, but I'm still having a problem...

I created a new Amber welcome app. I then installed nodemailer:

npm install nodemailer

This puts nodemailer in ./node_modules. Then I created nodemailer.amd.json in the project root:

{
   
"paths": {
       
"nodemailer": "."
   
}
}


Then I run:


grunt devel


In config.js, I see the line:

    "nodemailer": "node_modules/nodemailer",

Wunderbar! This looks correct.

I start the application and add the following import to the application Package:

 imports: {'amber/jquery/Wrappers-JQuery'. 'amber/web/Web'. 'silk/Silk'. 'nodemailer'}

AFAICT, I'm following the instructions I've found scattered everywhere on the web. So this should work...

However, it kills my application. It doesn't load properly because I can't start Helios. And the application does not work – neither "Hello from Silk >> TAG:" nor the other two buttons will do anything.

Where did I go wrong?


On Monday, 8 June 2015 09:48:00 UTC-4, Herby wrote:


Richard Eng wrote:
> The docs for integrating external JS libs are still in a bit of a
> mess. I'm trying to distill all of it to something *very simple*. So I
> would like to use the Nodemailer library. I've installed it:
>
> ||
> npm install -g nodemailer

-g ???

> In the nodemailer directory, I've created a local.amd.json file:

WRONG, WRONG, WRONG! YOU NEVER DO THAT!
There's libdir.amd.json for that.

Read the "Lego analogy" amber wiki article and github/herby/amd-config-builder README.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Require Nodemailer

Herby Vojčík


Dňa 8. júna 2015 22:34:21 CEST používateľ Richard Eng <[hidden email]> napísal:

> I *think* I'm on the right track, but I'm still having a problem...
>
> I created a new Amber welcome app. I then installed nodemailer:
>
> npm install nodemailer
>
> This puts nodemailer in ./node_modules. Then I created
> nodemailer.amd.json
> in the project root:
>
> {
>     "paths": {
>         "nodemailer": "."
>     }
> }
>
>
> Then I run:
>
>
> grunt devel
>
>
> In config.js, I see the line:
>
>     "nodemailer": "node_modules/nodemailer",
>
> Wunderbar! This looks correct.

It is correct, if you wanted a. It is not correct, if ypu wanted b.

There are two modes of how to include an external library into a project. It in fact depends on how is that library organized, and you choose the mode depending on what you actually map in paths section in .amd.json:

 a. Library is a set of many files in a directory tree. They often want to know each other and point between them using relative (./foo, ../bar) module ids. In this case, you want to map the root of the tree (like "foo": "."), and use module ids like "foo/bar" and "foo/baz/quux". Foe an example, see how helios includes bootstrap or codemirror.

This is what you did in the mapping part.

 b. Library is more or less only one file plus some infrastructure (bower.json, LICENSE, etc.). In this case you want to map directly the file with the library itself, sans .js, for example "jquery": "jquery" and use the mapped name directly as module id. For an example, see how helios includes jquery or showdown (IIRC).

This is what you did on import side.

You cannot mix them. If you mapba directory and then want to load it as a file, yoy cannot blame requirwjs that it fails.

>
> I start the application and add the following import to the
> application
> Package:
>
> imports: {'amber/jquery/Wrappers-JQuery'. 'amber/web/Web'.
> 'silk/Silk'.
> 'nodemailer'}
>
> AFAICT, I'm following the instructions I've found scattered everywhere
> on
> the web. So this *should* work...
>
> However, it kills my application. It doesn't load properly because I
> can't
> start Helios. And the application does not work – neither "Hello from
> Silk
> >> TAG:" nor the other two buttons will do anything.
>
> Where did I go wrong?
>
>
> On Monday, 8 June 2015 09:48:00 UTC-4, Herby wrote:
> >
> >
> >
> > Richard Eng wrote:
> > > The docs for integrating external JS libs are still in a bit of a
> > > mess. I'm trying to distill all of it to something *very simple*.
> So I
> > > would like to use the Nodemailer library. I've installed it:
> > >
> > > ||
> > > npm install -g nodemailer
> >
> > -g ???
> >
> > > In the nodemailer directory, I've created a local.amd.json file:
> >
> > WRONG, WRONG, WRONG! YOU NEVER DO THAT!
> > There's libdir.amd.json for that.
> >
> > Read the "Lego analogy" amber wiki article and
> > github/herby/amd-config-builder README.
> >
> >

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Require Nodemailer

Herby Vojčík


Dňa 8. júna 2015 23:01:14 CEST používateľ "Herby Vojčík" <[hidden email]> napísal:

>
> There are two modes of how to include an external library into a
> project. It in fact depends on how is that library organized, and you
> choose the mode depending on what you actually map in paths section in
> .amd.json:
>
> a. Library is a set of many files in a directory tree. They often want
> to know each other and point between them using relative (./foo,
> ../bar) module ids. In this case, you want to map the root of the tree
> (like "foo": "."), and use module ids like "foo/bar" and
> "foo/baz/quux". Foe an example, see how helios includes bootstrap or
> codemirror.
>
> This is what you did in the mapping part.
>
> b. Library is more or less only one file plus some infrastructure
> (bower.json, LICENSE, etc.). In this case you want to map directly the
> file with the library itself, sans .js, for example "jquery": "jquery"
> and use the mapped name directly as module id. For an example, see how
> helios includes jquery or showdown (IIRC).
>
> This is what you did on import side.
>
> You cannot mix them. If you mapba directory and then want to load it
> as a file, yoy cannot blame requirwjs that it fails.

One small style / convention note: b is preferred.


--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Require Nodemailer

Herby Vojčík
In reply to this post by horrido
One small question: are you doing a server-side project to be run on node or browser-based app/lib? I presume the latter is true. In that case, do nor use bpm to get your library. Use bower, always when possible. It should always be bower.json which describes your dependencies, so tpu can seamlesslt work with all the rest (publiah as reusable module, detect cetsion clashes, etc.). Npm is _not_ for browset-side libraries.

Even if a project is not regiatered in bowet tegistry, there is always possibility to `bower install name git://github.com/user/repo.git --save`, and versioning also works if publisher have semver-compatible releases (even if not, you can select any tag/branch by `bower install name "git://github.com/user/repo.git#branch_or_tag"; --save`, but you lose semver goodies like updating to compatible higher version etc.

Dňa 8. júna 2015 22:34:21 CEST používateľ Richard Eng <[hidden email]> napísal:
I think I'm on the right track, but I'm still having a problem...

I created a new Amber welcome app. I then installed nodemailer:

npm install nodemailer

This puts nodemailer in ./node_modules. Then I created nodemailer.amd.json in the project root:

{
   
"paths": {
       
"nodemailer": "."
   
}
}


Then I run:


grunt devel


In config.js, I see the line:

    "nodemailer": "node_modules/nodemailer",

Wunderbar! This looks correct.

I start the application and add the following import to the application Package:

 imports: {'amber/jquery/Wrappers-JQuery'. 'amber/web/Web'. 'silk/Silk'. 'nodemailer'}

AFAICT, I'm following the instructions I've found scattered everywhere on the web. So this should work...

However, it kills my application. It doesn't load properly because I can't start Helios. And the application does not work – neither "Hello from Silk >> TAG:" nor the other two buttons will do anything.

Where did I go wrong?


On Monday, 8 June 2015 09:48:00 UTC-4, Herby wrote:


Richard Eng wrote:
> The docs for integrating external JS libs are still in a bit of a
> mess. I'm trying to distill all of it to something *very simple*. So I
> would like to use the Nodemailer library. I've installed it:
>
> ||
> npm install -g nodemailer

-g ???

> In the nodemailer directory, I've created a local.amd.json file:

WRONG, WRONG, WRONG! YOU NEVER DO THAT!
There's libdir.amd.json for that.

Read the "Lego analogy" amber wiki article and github/herby/amd-config-builder README.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Require Nodemailer

horrido
After some more digging, I've learned that JavaScript and browsers are not equipped to send emails purely from the client side – you need the assistance of server side. So my attempt to integrate nodemailer (or ANY JS mailer) is misguided and a waste of time.

This got me thinking... Browsers have many limitations with respect to what you can do on the client side. You can't access databases on the client. You can't send emails. It seems to me that client-side web applications are not as broadly useful as server-side web applications. You can't always transform a server-side app into a client-side app.

Strange that everyone is so excited about Ember, Angular, Meteor, etc.


On Monday, 8 June 2015 17:23:48 UTC-4, Herby wrote:
One small question: are you doing a server-side project to be run on node or browser-based app/lib? I presume the latter is true. In that case, do nor use bpm to get your library. Use bower, always when possible. It should always be bower.json which describes your dependencies, so tpu can seamlesslt work with all the rest (publiah as reusable module, detect cetsion clashes, etc.). Npm is _not_ for browset-side libraries.

Even if a project is not regiatered in bowet tegistry, there is always possibility to `bower install name git://<a href="http://github.com/user/repo.git" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fgithub.com%2Fuser%2Frepo.git\46sa\75D\46sntz\0751\46usg\75AFQjCNFzQTy4z6132I2CrhlDGPJ-_FvX_g';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fgithub.com%2Fuser%2Frepo.git\46sa\75D\46sntz\0751\46usg\75AFQjCNFzQTy4z6132I2CrhlDGPJ-_FvX_g';return true;">github.com/user/repo.git --save`, and versioning also works if publisher have semver-compatible releases (even if not, you can select any tag/branch by `bower install name "git://<a href="http://github.com/user/repo.git#branch_or_tag&amp;quot" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fgithub.com%2Fuser%2Frepo.git%23branch_or_tag%26quot\46sa\75D\46sntz\0751\46usg\75AFQjCNHKsQQSw160XEn97F5-GISO68HrCQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fgithub.com%2Fuser%2Frepo.git%23branch_or_tag%26quot\46sa\75D\46sntz\0751\46usg\75AFQjCNHKsQQSw160XEn97F5-GISO68HrCQ';return true;">github.com/user/repo.git#branch_or_tag&quot; --save`, but you lose semver goodies like updating to compatible higher version etc.

Dňa 8. júna 2015 22:34:21 CEST používateľ Richard Eng <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="JspoRgDZcWgJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">horrido...@...> napísal:
I think I'm on the right track, but I'm still having a problem...

I created a new Amber welcome app. I then installed nodemailer:

npm install nodemailer

This puts nodemailer in ./node_modules. Then I created nodemailer.amd.json in the project root:

{
   
"paths": {
       
"nodemailer": "."
   
}
}


Then I run:


grunt devel


In config.js, I see the line:

    "nodemailer": "node_modules/nodemailer",

Wunderbar! This looks correct.

I start the application and add the following import to the application Package:

 imports: {'amber/jquery/Wrappers-JQuery'. 'amber/web/Web'. 'silk/Silk'. 'nodemailer'}

AFAICT, I'm following the instructions I've found scattered everywhere on the web. So this should work...

However, it kills my application. It doesn't load properly because I can't start Helios. And the application does not work – neither "Hello from Silk >> TAG:" nor the other two buttons will do anything.

Where did I go wrong?


On Monday, 8 June 2015 09:48:00 UTC-4, Herby wrote:


Richard Eng wrote:
> The docs for integrating external JS libs are still in a bit of a
> mess. I'm trying to distill all of it to something *very simple*. So I
> would like to use the Nodemailer library. I've installed it:
>
> ||
> npm install -g nodemailer

-g ???

> In the nodemailer directory, I've created a local.amd.json file:

WRONG, WRONG, WRONG! YOU NEVER DO THAT!
There's libdir.amd.json for that.

Read the "Lego analogy" amber wiki article and github/herby/amd-config-builder README.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Require Nodemailer

Herby Vojčík


Richard Eng wrote:
> After some more digging, I've learned that JavaScript and browsers are
> not equipped to send emails purely from the client side – you need the
> assistance of server side. So my attempt to integrate nodemailer (or ANY
> JS mailer) is misguided and a waste of time.

That, too. But you can write a server part, as well.

> This got me thinking... Browsers have many limitations with respect to
> what you can do on the client side. You can't access databases on the
> client. You can't send emails. It seems to me that client-side web
> applications are not as broadly useful as server-side web applications.

You're mixing server-side applications with server-side services and
thus draw very wrong conclusion. Client-side app can do everything -
with an API to perform out-of-client things. And those server-side APIs
are available for nearly anything. Just sign up, get API key, choose a
plan, pay and use.

That's why "everyone is excited" below. The model has shifted.

> _You can't always transform a server-side app into a client-side app_.

But of course you can. But if you cannot find stock version of your
at-server-side-services as described above, you must have some server of
your own (also leasable and payable, eg. DigitalOcean). The difference
is, you transform it from server-side app to server-side service +
client-side app.

And you can write server-side in Amber, as well.

> Strange that everyone is so excited about Ember, Angular, Meteor, etc.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Require Nodemailer

horrido
Thanks for the clarification. For the longest time, I had the wrong conception of what a "client-side web application" was. I thought it could be totally client-side execution without communicating with a server. How this idea got into my head, I'll never know.


On Tuesday, 9 June 2015 06:12:51 UTC-4, Herby wrote:


Richard Eng wrote:
> After some more digging, I've learned that JavaScript and browsers are
> not equipped to send emails purely from the client side – you need the
> assistance of server side. So my attempt to integrate nodemailer (or ANY
> JS mailer) is misguided and a waste of time.

That, too. But you can write a server part, as well.

> This got me thinking... Browsers have many limitations with respect to
> what you can do on the client side. You can't access databases on the
> client. You can't send emails. It seems to me that client-side web
> applications are not as broadly useful as server-side web applications.

You're mixing server-side applications with server-side services and
thus draw very wrong conclusion. Client-side app can do everything -
with an API to perform out-of-client things. And those server-side APIs
are available for nearly anything. Just sign up, get API key, choose a
plan, pay and use.

That's why "everyone is excited" below. The model has shifted.

> _You can't always transform a server-side app into a client-side app_.

But of course you can. But if you cannot find stock version of your
at-server-side-services as described above, you must have some server of
your own (also leasable and payable, eg. DigitalOcean). The difference
is, you transform it from server-side app to server-side service +
client-side app.

And you can write server-side in Amber, as well.

> Strange that everyone is so excited about Ember, Angular, Meteor, etc.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.