How to replace `Bower` to `Yarn` with `Yarn Workspaces`

How to replace Bower to Yarn with Yarn Workspaces Example: mean-project‘s structure | mean-project/ | —- package.json <—– `Node.js Server & development packages’ list` | —- bower.json <—– `Web Client packages’ list` | —- node_modules/ | —————– express/ <— `’package.json’ install dependencies` | —————– grunt/ <— `’package.json’ install devDependencies` | | —- client/ | ———–…

Read More

What is difference between `module.exports` and `export` in node.js?

ES Modules: Using Named Exports as the Default Export https://medium.com/@timoxley/named-exports-as-the-default-export-api-670b1b554f65 // in `cow.js` : export function speak () { return ‘moo’ } To use a named export, we can import it directly into our code: // in `import-named.js` : import { speak } from ‘./cow’; speak() // => ‘moo’ Aliasing named imports You can assign…

Read More

`bluebird@3.5.1`: MongoDB `mongoose@4.13.7` `Promises` library

bluebird@3.5.1: MongoDB mongoose@4.13.7 Promises library > Warning: a promise was created in a handler > at internal/process/next_tick.js:180:9 but was not returned from it, > see http://goo.gl/rRqMUw > at model.Query.ret [as execAsync] > (eval at makeNodePromisifiedEval > (/home/bike/github/SmartPlug-Foodtruck.kr/node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:8:21) > mongoose Promises : bluebird http://mongoosejs.com/docs/promises.html Built-in Promises Mongoose async operations, like .save() and queries, return Promises/A+…

Read More

Elasticsearch Custom Analyzer applied to Node.js Mongoosastic search

Installing Elasticsearch Custom Analyzer for Korean analysis(kr_analyzer) Check version of Elasticsearch $ curl -XGET ‘localhost:9200’ >result: { “name” : “Caprice”, “cluster_name” : “elasticsearch”, “version” : { “number” : “5.0.0-alpha4”, “build_hash” : “3f5b994”, “build_date” : “2016-06-27T16:23:46.861Z”, “build_snapshot” : false, “lucene_version” : “6.1.0” }, “tagline” : “You Know, for Search” } Test Elasticsearch Custom Analyzer, kr_analyzer Deleting…

Read More

Install Elastic Search Server and mongoosastic search pagination

Download and install Elasticsearch server https://www.elastic.co/downloads/elasticsearch Download and unzip the latest Elasticsearch distribution Run bin/elasticsearch on Unix or sudo dpkg -i elasticsearch-xxx.deb Run curl -X GET http://localhost:9200/ Install and set “mongoosastic” nodejs module npm install –save mongoosastic server: blog.model.js: [js] var mongoosastic = require(‘mongoosastic’); var BlogSchema = new mongoose.Schema({ … }); BlogSchema.methods = { ……

Read More

[mongoosastic] Install Elastic Search Server and mongoosastic for Node.js

Install Elastic Search server Download and install https://www.elastic.co/downloads/elasticsearch Download and unzip the latest Elasticsearch distribution Run bin/elasticsearch on Unix or sudo dpkg -i elasticsearch-xxx.deb Run curl -X GET http://localhost:9200/ Install and set “mongoosastic” nodejs module npm install –save mongoosastic server: blog.model.js: [js] var mongoosastic = require(‘mongoosastic’); var BlogSchema = new mongoose.Schema({ … }); BlogSchema.methods =…

Read More

[Angularjs] how to use ‘angular-paginate-anything’ pagination module

Client-side Aangularjs Install: bower install angular-paginate-anything –save Angularjs: app.js angular.module(‘myModule’, [‘bgf.paginateAnything’]); blog.controller.js [js] class BlogCtrl { constructor(Auth, Blog, $state, $stateParams, $http, $scope, $location, socket) { this.errors = {}; this.success = {}; this.submitted = false; this.Auth = Auth; this.Blog = Blog; this.$state = $state; this.$stateParams = $stateParams; this.blogs = []; $scope.url = ‘/api/blogs’; $scope.perPage = parseInt($location.search().perPage,…

Read More

[Angularjs] markdown editor modules: Install markdown angular-marked and highlight.js

Angularjs Markdown Modules Hypercubed/angular-marked highlight.js: Syntax highlighting for the Web Install markdown angular-marked and highlight.js Install modules: bower install –save highlightjs bower install –save angular-marked index.html: <!doctype html> <html lang=”en”> <head> <meta charset=”utf-8″> <!– build:css(client) app/vendor.css –> <!– bower:css –> <link rel=”stylesheet” href=”bower_components/highlightjs/styles/default.css” /> . . . <!– endbower –> <!– endbuild –> . .…

Read More

[bootstrap-markdown] show and hide markdown editor programmatically

html: [html] Edit [/html] Angularjs: [js] editComment(comment){ var self = this; var editor = angular.element($(`#${comment._id}`)); editor.markdown({autofocus: true, savable: true, hideable:true, onSave: function(e) {//e: markdown editor self.Blog.saveComment({ id: self.blog._id, comment_id: comment._id, content: e.getContent() }).$promise .then(() => { //angular.element($(‘.md-editor’)).children(‘.md-footer’).html(‘Comment is updated.’); var el = angular.element($(‘.md-editor’)).parents(‘.panel’); el.css( “background-color”, “#ffeeff” ); setTimeout(() => { el.css( “background-color”, “#ffffff” ); },…

Read More

[mongoose] update and delete embedded document in array

Update: var comment = blog.comments.id(comment_id); comment.author = ‘Bruce Wayne’; blog.save(function (err) { // emmbeded comment with author updated }); Delete: Blog.findByIdAndUpdateAsync(blogId, { $pull: { comments: {_id: commentId}} }) .then(blog => { res.status(200).json(‘Comment is deleted successfully.’); }) .catch(err => { console.error(err); res.status(500).json(err.message || err); });

Read More