@compas/stdlib
Advanced tools
Comparing version 0.0.190 to 0.0.191
@@ -22,4 +22,2 @@ export { uuid } from "./src/datatypes.js"; | ||
refreshEnvironmentCache, | ||
calculateCorsUrlFromAppUrl, | ||
calculateCookieUrlFromAppUrl, | ||
} from "./src/env.js"; | ||
@@ -26,0 +24,0 @@ export { |
@@ -47,4 +47,2 @@ /// <reference path="./types/advanced-types.d.ts"> | ||
refreshEnvironmentCache, | ||
calculateCorsUrlFromAppUrl, | ||
calculateCookieUrlFromAppUrl, | ||
} from "./src/env.js"; | ||
@@ -51,0 +49,0 @@ |
{ | ||
"name": "@compas/stdlib", | ||
"version": "0.0.190", | ||
"version": "0.0.191", | ||
"description": "All kinds of utility functions", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -70,3 +70,2 @@ # @compas/stdlib | ||
- Send file helper | ||
- Session support with safe, browser readable cookies | ||
@@ -77,2 +76,3 @@ **@compas/store**: | ||
- Wrapper around Postgres connection | ||
- Session support via JSON Web tokens | ||
- Utilities for providing temporary databases in a test environment | ||
@@ -79,0 +79,0 @@ - Postgres migrations |
@@ -41,28 +41,2 @@ /** | ||
/** | ||
* Try to calculate the CORS_URL environment variable from the APP_URL environment | ||
* variable. Assumes the APP_URL is in the following format: http(s)://api.xxx.xx.com and | ||
* generates the following CORS_URL value: http(s)://xxx.xx.com. | ||
* If the APP_URL host only contains xxx.com the CORS_URL value will be equivalent. | ||
* | ||
* Refreshing the environment cache via `refreshEnvironmentCache` is not necessary. | ||
* | ||
* @since 0.1.0 | ||
* | ||
* @returns {void} | ||
*/ | ||
export function calculateCorsUrlFromAppUrl(): void; | ||
/** | ||
* Try to calculate the COOKIE_URL environment variable from the APP_URL environment | ||
* variable. Assumes the APP_URL is in the following format: http(s)://api.xxx.xx.com and | ||
* generates the following COOKIE_URL value: xxx.xx.com. | ||
* If the APP_URL host only contains xxx.com the CORS_URL value will be equivalent. | ||
* | ||
* Refreshing the environment cache via `refreshEnvironmentCache` is not necessary. | ||
* | ||
* @since 0.1.0 | ||
* | ||
* @returns {void} | ||
*/ | ||
export function calculateCookieUrlFromAppUrl(): void; | ||
/** | ||
* Cached process.env | ||
@@ -69,0 +43,0 @@ * |
@@ -57,56 +57,1 @@ /** | ||
} | ||
/** | ||
* Try to calculate the CORS_URL environment variable from the APP_URL environment | ||
* variable. Assumes the APP_URL is in the following format: http(s)://api.xxx.xx.com and | ||
* generates the following CORS_URL value: http(s)://xxx.xx.com. | ||
* If the APP_URL host only contains xxx.com the CORS_URL value will be equivalent. | ||
* | ||
* Refreshing the environment cache via `refreshEnvironmentCache` is not necessary. | ||
* | ||
* @since 0.1.0 | ||
* | ||
* @returns {void} | ||
*/ | ||
export function calculateCorsUrlFromAppUrl() { | ||
const appUrl = new URL(environment.APP_URL); | ||
const hostParts = appUrl.host.split("."); | ||
const protocol = appUrl.protocol; | ||
let corsUrl = ""; | ||
if (hostParts.length === 2) { | ||
corsUrl = `${protocol}//${appUrl.host}`; | ||
} else { | ||
corsUrl = `${protocol}//${hostParts.slice(1).join(".")}`; | ||
} | ||
environment.CORS_URL = corsUrl; | ||
process.env.CORS_URL = corsUrl; | ||
} | ||
/** | ||
* Try to calculate the COOKIE_URL environment variable from the APP_URL environment | ||
* variable. Assumes the APP_URL is in the following format: http(s)://api.xxx.xx.com and | ||
* generates the following COOKIE_URL value: xxx.xx.com. | ||
* If the APP_URL host only contains xxx.com the CORS_URL value will be equivalent. | ||
* | ||
* Refreshing the environment cache via `refreshEnvironmentCache` is not necessary. | ||
* | ||
* @since 0.1.0 | ||
* | ||
* @returns {void} | ||
*/ | ||
export function calculateCookieUrlFromAppUrl() { | ||
const appUrl = new URL(environment.APP_URL); | ||
const hostParts = appUrl.host.split("."); | ||
let cookieUrl = appUrl.host; | ||
if (hostParts.length !== 2) { | ||
cookieUrl = hostParts.slice(1).join("."); | ||
} | ||
environment.COOKIE_URL = cookieUrl; | ||
process.env.COOKIE_URL = cookieUrl; | ||
} |
Sorry, the diff of this file is not supported yet
75434
2520