Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative DB URLs #1319

Merged
merged 41 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4b537b6
removed usage of remote_url
TheSlimvReal Jun 23, 2022
3a12b4c
removed database name from config
TheSlimvReal Jun 23, 2022
39dd063
added comments for proxy url
TheSlimvReal Jun 24, 2022
031ee25
removed usages of remote_url for database
TheSlimvReal Jun 24, 2022
3e8e55a
fixed lint error
TheSlimvReal Jun 24, 2022
b36e871
Merge remote-tracking branch 'origin/master' into relative-url
TheSlimvReal Jul 6, 2022
6b5b981
removed remote_url from default config
TheSlimvReal Jul 6, 2022
93974ce
removed database name and replaced it by a static value
TheSlimvReal Jul 6, 2022
faeca34
removed site_name from config.json and moved it to db config
TheSlimvReal Jul 6, 2022
b4f7b06
fixed tests
TheSlimvReal Jul 6, 2022
6f25216
removed session type from config.json and moved it environment or que…
TheSlimvReal Jul 6, 2022
70d87d4
added default env options to prod settings
TheSlimvReal Jul 7, 2022
edcfba0
added demo redirect to nginx conf and option to disable it to dockerfile
TheSlimvReal Jul 8, 2022
b502680
cleaned up initialization of AppConfig settings and removed old refer…
TheSlimvReal Jul 8, 2022
e7f2ff8
fixed tests
TheSlimvReal Jul 8, 2022
150963f
Merge branch 'master' into relative-url
TheSlimvReal Jul 8, 2022
aee3697
fix doc styling
TheSlimvReal Jul 8, 2022
6503623
Merge remote-tracking branch 'origin/relative-url' into relative-url
TheSlimvReal Jul 8, 2022
39091ab
disabled port in redirect
TheSlimvReal Jul 8, 2022
f8d81d1
fixed typo
TheSlimvReal Jul 8, 2022
eb0cca5
better rewriting to use correct port and schema
TheSlimvReal Jul 8, 2022
e8d9b1d
using https on default
TheSlimvReal Jul 8, 2022
688cddb
changed try-files clause for language locations
TheSlimvReal Jul 11, 2022
862eb3c
directly navigating to index.html file on language change
TheSlimvReal Jul 11, 2022
1f34781
Merge remote-tracking branch 'origin/master' into relative-url
TheSlimvReal Jul 19, 2022
35a62c1
added automatic demo query params to new nginx config
TheSlimvReal Jul 19, 2022
0ea0c8c
Merge remote-tracking branch 'origin/relative-url' into relative-url
TheSlimvReal Jul 19, 2022
281f97d
files are captured in separate location block
TheSlimvReal Jul 19, 2022
62a6673
enforcing https in rewrite
TheSlimvReal Jul 19, 2022
579dc82
using correct host variable
TheSlimvReal Jul 19, 2022
da65aee
added local storage option to preserve query params
TheSlimvReal Jul 19, 2022
90a0273
using permanent rewrite for demo mode
TheSlimvReal Jul 19, 2022
9b407e1
improved documentation
TheSlimvReal Jul 19, 2022
db88268
added comment about heroku workaround
TheSlimvReal Jul 19, 2022
1ff29ab
removed webdav references
TheSlimvReal Jul 27, 2022
2ef6fd8
cleaned up demo check in nginx config
TheSlimvReal Jul 27, 2022
13985d3
cleaned up fetching of runtime settings
TheSlimvReal Jul 27, 2022
1532db3
renamed AppConfig to AppSettings
TheSlimvReal Jul 27, 2022
18de486
changed order of config attributes
TheSlimvReal Jul 27, 2022
fb3df4b
removed config.default.json
TheSlimvReal Jul 27, 2022
474572e
moved demo_mode and session_type to environment.ts
TheSlimvReal Jul 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ server {
root /usr/share/nginx/html;
}

# The proxy path should be the same as in AppConfig.DB_PROXY_PREFIX
location /db {
rewrite /db/(.*) /$1 break;
proxy_pass ${COUCHDB_URL};
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("AppComponent", () => {
let entityUpdates: Subject<UpdatedEntity<Config>>;

const mockAppSettings: IAppConfig = {
database: { name: "", remote_url: "" },
database: { name: "" },
session_type: SessionType.local,
demo_mode: false,
site_name: "",
Expand Down
5 changes: 1 addition & 4 deletions src/app/core/admin/admin/admin.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ describe("AdminComponent", () => {
AppConfig.settings = {
site_name: "",
session_type: SessionType.mock,
database: {
name: "unit-tests",
remote_url: "",
},
database: { name: "unit-tests" },
};

TestBed.configureTestingModule({
Expand Down
7 changes: 0 additions & 7 deletions src/app/core/app-config/app-config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ export interface IAppConfig {
database: {
TheSlimvReal marked this conversation as resolved.
Show resolved Hide resolved
/** name of the database - both remote and local */
name: string;

/**
* URL to the database server to be synced with
*
* Beware of CORS issues if this is on a different domain than the app is served from.
*/
remote_url: string;
};

/**
Expand Down
2 changes: 2 additions & 0 deletions src/app/core/app-config/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import { IAppConfig } from "./app-config.model";
* // no need for dependency injection here
*/
export class AppConfig {
TheSlimvReal marked this conversation as resolved.
Show resolved Hide resolved
/** Path for the reverse proxy that forwards to the database - configured in `proxy.conf.json` and `default.conf` */
static DB_PROXY_PREFIX = "/db";
/** settings for the app */
static settings: IAppConfig;

Expand Down
5 changes: 1 addition & 4 deletions src/app/core/session/session-service/local-session.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ describe("LocalSessionService", () => {
AppConfig.settings = {
site_name: "Aam Digital - DEV",
session_type: SessionType.mock,
database: {
name: "test-db-name",
remote_url: "https://demo.aam-digital.com/db/",
},
database: { name: "test-db-name" },
};
database = jasmine.createSpyObj([
"initInMemoryDB",
Expand Down
5 changes: 1 addition & 4 deletions src/app/core/session/session-service/remote-session.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ describe("RemoteSessionService", () => {
AppConfig.settings = {
site_name: "test",
session_type: SessionType.mock,
database: {
name: "database",
remote_url: "database_url",
},
database: { name: "database" },
};
mockHttpClient = jasmine.createSpyObj(["post", "delete"]);
mockHttpClient.delete.and.returnValue(of());
Expand Down
17 changes: 14 additions & 3 deletions src/app/core/session/session-service/remote-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { SessionService } from "./session.service";
import { LoginState } from "../session-states/login-state.enum";
import { PouchDatabase } from "../../database/pouch-database";
import { LoggingService } from "../../logging/logging.service";
import PouchDB from "pouchdb-browser";

/**
* Responsibilities:
Expand All @@ -47,9 +48,19 @@ export class RemoteSession extends SessionService {
) {
super();
this.database = new PouchDatabase(this.loggingService).initIndexedDB(
AppConfig.settings.database.remote_url + AppConfig.settings.database.name,
`${AppConfig.DB_PROXY_PREFIX}/${AppConfig.settings.database.name}`,
{
adapter: "http",
skip_setup: true,
fetch: (url, opts) => {
if (typeof url === "string") {
return PouchDB.fetch(
AppConfig.DB_PROXY_PREFIX +
url.split(AppConfig.DB_PROXY_PREFIX)[1],
opts
);
}
},
}
);
}
Expand All @@ -63,7 +74,7 @@ export class RemoteSession extends SessionService {
try {
const response = await this.httpClient
.post<DatabaseUser>(
`${AppConfig.settings.database.remote_url}_session`,
`${AppConfig.DB_PROXY_PREFIX}/_session`,
{ name: username, password: password },
{ withCredentials: true }
)
Expand Down Expand Up @@ -103,7 +114,7 @@ export class RemoteSession extends SessionService {
*/
public async logout(): Promise<void> {
await this.httpClient
.delete(`${AppConfig.settings.database.remote_url}_session`, {
.delete(`${AppConfig.DB_PROXY_PREFIX}/_session`, {
withCredentials: true,
})
.toPromise()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ describe("SyncedSessionService", () => {
AppConfig.settings = {
site_name: "Aam Digital - DEV",
session_type: SessionType.mock,
database: {
name: "integration_tests",
remote_url: "https://demo.aam-digital.com/db/",
},
database: { name: "integration_tests" },
webdav: { remote_url: "" },
};
sessionService = TestBed.inject(SyncedSessionService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class SyncedSessionService extends SessionService {
*/
checkForValidSession() {
this.httpClient
.get(`${AppConfig.settings.database.remote_url}_session`, {
.get(`${AppConfig.DB_PROXY_PREFIX}/_session`, {
withCredentials: true,
})
.subscribe((res: any) => {
Expand Down
5 changes: 1 addition & 4 deletions src/app/core/webdav/cloud-file-service.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ describe("CloudFileService", () => {
AppConfig.settings = {
site_name: "",
session_type: SessionType.mock,
database: {
name: "unit-tests",
remote_url: "",
},
database: { name: "unit-tests" },
webdav: { remote_url: "test-url" },
};

Expand Down
5 changes: 1 addition & 4 deletions src/app/utils/mocked-testing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ export class MockedTestingModule {
AppConfig.settings = {
site_name: "Aam Digital - DEV",
session_type: SessionType.mock,
database: {
name: "test-db-name",
remote_url: "https://demo.aam-digital.com/db/",
},
database: { name: "test-db-name" },
};
const mockedEntityMapper = mockEntityMapper([new User(TEST_USER), ...data]);
const session = createLocalSession(loginState === LoginState.LOGGED_IN);
Expand Down
5 changes: 1 addition & 4 deletions src/app/utils/performance-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ xdescribe("Performance Tests", () => {
AppConfig.settings = {
site_name: "Aam Digital - DEV",
session_type: SessionType.mock, // change to SessionType.local to run performance tests with the InBrowser database
database: {
name: "test-db-name",
remote_url: "https://demo.aam-digital.com/db/",
},
database: { name: "test-db-name" },
};

await TestBed.configureTestingModule({
Expand Down