code-push login
code-push logout
code-push whoami
| // Easy Frontend | |
| // Học FE đơn giản, dễ hiểu và đặc biệt phải vui ❤️ | |
| // JS NÂNG CAO - Xử lý expired token trong Javascript như thế nào? | |
| // ❓ Chuyện gì xảy ra nếu giữa chừng token bị expired? | |
| // Ví dụ: 3 api requests đồng thời với nhau | |
| // TRƯỜNG HỢP 1: Token chưa expired, vẫn còn tốt chán 🤣 | |
| // --request 1--> |
| import NodeCache from 'node-cache'; | |
| class Cache { | |
| constructor(ttlSeconds) { | |
| this.cache = new NodeCache({ stdTTL: ttlSeconds, checkperiod: ttlSeconds * 0.2, useClones: false }); | |
| } | |
| get(key, storeFunction) { | |
| const value = this.cache.get(key); |
| //var salt = CryptoJS.lib.WordArray.random(256/32); | |
| //var iv = CryptoJS.lib.WordArray.random(256/32); | |
| //console.log('salt '+ salt ); | |
| //console.log('iv '+ iv ); | |
| var salt = CryptoJS.enc.Hex.parse("28698aadc97f3ad8"); | |
| var iv = CryptoJS.enc.Hex.parse("73ac39603da6e205"); | |
| console.log('salt '+ salt ); | |
| console.log('iv '+ iv ); | |
| var key128Bits = CryptoJS.PBKDF2("Secret Passphrase", salt, { keySize: 256/32 }); |
| version: "3" | |
| services: | |
| mongo1: | |
| hostname: mongo1 | |
| container_name: localmongo1 | |
| image: mongo:4.0-xenial | |
| expose: | |
| - 27017 | |
| ports: | |
| - 27011:27017 |
| import EXIF from 'exif-js'; | |
| const hasBlobConstructor = typeof (Blob) !== 'undefined' && (function checkBlobConstructor() { | |
| try { | |
| return Boolean(new Blob()); | |
| } catch (error) { | |
| return false; | |
| } | |
| }()); |
http://www.oreilly.com/programming/free/files/microservices-for-java-developers.pdf
http://www.oreilly.com/programming/free/files/microservices-for-java-developers.epub
http://www.oreilly.com/programming/free/files/microservices-for-java-developers.mobi
http://www.oreilly.com/programming/free/files/modern-java-ee-design-patterns.pdf
http://www.oreilly.com/programming/free/files/modern-java-ee-design-patterns.epub
http://www.oreilly.com/programming/free/files/modern-java-ee-design-patterns.mobi
Last updated: 2021-02-21, tested with socket.io v3.1.1
This is the simplest implementation you will find for a client/server WebSockets architecture using socket.io.
To see a full explanation, read my answer on SO here: https://stackoverflow.com/a/24232050/778272.
If you're looking for examples using frameworks, check these links:
| // Feeds model after cache | |
| import DB from '../db'; | |
| import CacheService from '../cache.service'; | |
| const ttl = 60 * 60 * 1; // cache for 1 Hour | |
| const cache = new CacheService(ttl); // Create a new cache service instance | |
| const FeedModel = { |