next.js, nginx, reverse-proxy, ssl
$ sudo apt-get update
$ sudo apt-get install nginx letsencrypt| package main | |
| import "fmt" | |
| func main() { | |
| fmt.Println("hello world") | |
| } |
| map $http_origin $allow_origin { | |
| default ""; | |
| "~^https?://(?:[^/]*\.)?(stevebuzonas\.(?:com|local))(?::[0-9]+)?$" "$http_origin"; | |
| } | |
| map $request_method $cors_method { | |
| default "allowed"; | |
| "OPTIONS" "preflight"; | |
| } |
| #!/usr/bin/env python | |
| # details on rabbitMQ password hashing | |
| # https://www.rabbitmq.com/passwords.html#computing-password-hash | |
| from __future__ import print_function | |
| import base64 | |
| import os | |
| import hashlib | |
| import struct | |
| import getpass |
| /*** function that used as middleware ***/ | |
| accessToken: async (name) => { | |
| if (typeof document === "undefined") return ""; | |
| let token = document.cookie | |
| .split(";") | |
| .filter((cookie) => cookie.startsWith("token"))[0]; | |
| if (!token) { | |
| const response = await fetch("/api/refresh", { method: "POST" }); |
| /** | |
| * Plural forms for russian words | |
| * @param {Integer} count quantity for word | |
| * @param {Array} words Array of words. Example: ['депутат', 'депутата', 'депутатов'], ['коментарий', 'коментария', 'комментариев'] | |
| * @return {String} Count + plural form for word | |
| */ | |
| function pluralize(count, words) { | |
| var cases = [2, 0, 1, 1, 1, 2]; | |
| return count + ' ' + words[ (count % 100 > 4 && count % 100 < 20) ? 2 : cases[ Math.min(count % 10, 5)] ]; | |
| } |