Posts

Showing posts from August, 2020

Hãy sử dụng ESLint cho dự án của bạn!

Bài viết gốc: https://manhhomienbienthuy.bitbucket.io/2018/May/20/we-should-use-eslint-in-project.html (đã xin phép tác giả ) JavaScript đã trở thành một ngôn ngữ cực kỳ phổ biến trong lập trình web. Gần như bất cứ lập trình viên web nào cũng đều phải biết code JavaScript. Thế nhưng biết là một chuyện, code tốt lại là chuyện khác. Trong bài viết này, tôi sẽ giới thiệu một công cụ giúp chúng ta code JavaScript tốt hơn, đó chính là ESLint. Mở đầu Hiện nay JavaScript đã có những phát triển rất xa so với những thế hệ ban đầu, khi mà những đặc tả ES2015 (ECMAScript 2015 - ES6) và ES2017 được công bố. Đặc biệt, rất nhiều thư viện của JavaScript như ReactJS , AngularJS , VueJS , v.v... giúp chúng ta có thể xây dựng những ứng dụng web cực kỳ cool. Mặc dù có những đặc tả kỹ thuật như vậy, nhưng việc code JavaScript hiện nay vẫn còn rất nhiều vấn đề. Vì vậy, việc đảm bảo chất lượng của code JavaScript vẫn luôn là một thách thức lớn. Có rất nhiều yếu tốt để tạo ra một project ...

Deploy Node.js App with GitLab CI/CD

https://medium.com/@seulkiro/deploy-node-js-app-with-gitlab-ci-cd-214d12bfeeb5

Continuous Integration with Node.js, Heroku and GitLab CI/CD -Part 2.

Image
In the last part , we able to set up our git repository on GitLab set up our Node app with Express and write one unit test. In this part, we’ll cover the following: Setup of the app on Heroku GitLab CI/CD configuration using the .gitlab-ci.yml file GitLab repository:- https://gitlab.com/Mjeck/node-heroku-gitlab That done next is to create our app on Heroku. If you don’t have an account yet navigate to https://heroku.com and create a free account. With that done log on to your Heroku dashboard and create a new app. Create a new app on Heroku. Next, we go to our project directory in our code editor and create a new file and .gitlab-ci.yml paste the following code. # Node docker image on which this would be run image: node:8.10.0 cache: paths: - node_modules/ stages: - test - deploy_production # Job 1: Test: stage: test script: - npm install - npm run test # Job 2: # Deploy to staging Production: image: ruby:latest only: - ma...

Continuous Integration with Node.js, Heroku and GitLab CI/CD -Part 1.

Image
https://hocweb.vn/deploy-app-nodejs-voi-gitlab-ci-cd/ https://medium.com/@McDave95/continuous-integration-with-node-js-heroku-and-gitlab-ci-cd-part-1-1fe93a1d5967 CI/CD can be a mess at times, especially for newbies. The stress of having to use products you aren’t familiar with. But with GitLab’s integrated CI/CD feature it takes most of the hassle away. What we’ll achieve: Setup a node server with the express npm package Setup GitLab CI/CD Write Unit Test Deploy app on Heroku Prerequisites: A GitLab account Little understanding of Node.js Git and Node installed on your system Favourite Editor of choice ( ….visual studio code) GitLab repository:- https://gitlab.com/Mjeck/node-heroku-gitlab So our app would just take in two inputs, adds them together and returns the answer. Not so much you might say. Dependencies: express: — for handling our web server body-parser: — Node.js body parsing middleware. mocha: — test framework to run...

Tổng quan về PM2

Image
Mình vừa trở về sau khi tham gia chuyển đổi hệ thống cho một dự án. Ban đầu dự án này xây dựng dựa trên nền tảng duy nhất là PHP 5.5 build trên một VPS tại Singapore. Là thành viên trong bất kỳ dự án nào, mình luôn mong muốn đem lại những trải nghiệm tốt nhất tới người sử dụng, một khi họ truy cập vào website. Và các thành viên trong team đều ý thức được rằng đó là một trong những yếu tố quan trọng ảnh hưởng tới tỉ lệ giữ chân người dùng. Do đó hệ thống sẽ phải có những thay đổi, đặc biệt là tốc độ tải trang phải nhanh và ổn định trong khi dự án sẽ ngày một phình to hơn. Đó là lý do Nodejs được lựa chọn và áp dụng. Tại sao sử dụng PM2? Khi mới cài đặt, chưa có một tool nào được tích hợp để phục vụ cho deployment cho nodejs app. Và đó thực sự là vấn đề cần được giải quyết ngay. Khi bạn chạy một Nodejs app, tức là đang tạo ra một process mới (tiến trình mới) trên server. Chúng ta cần một trình quản lý process với nhiều yêu cầu được đặt ra: Ổn định, tin cậy để giữ ser...