feat: migrate frontend app to nextjs app router

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-05-29 17:32:44 +02:00
parent 5b5dabc84e
commit 8602645bea
108 changed files with 893 additions and 1188 deletions

View file

@ -5,6 +5,7 @@
*/
import { GetApiRequestBuilder } from '../common/api-request-builder/get-api-request-builder'
import type { FrontendConfig } from './types'
import { isBuildTime } from '../../utils/test-modes'
/**
* Fetches the frontend config from the backend.
@ -12,7 +13,10 @@ import type { FrontendConfig } from './types'
* @return The frontend config.
* @throws {Error} when the api request wasn't successful.
*/
export const getConfig = async (baseUrl?: string): Promise<FrontendConfig> => {
export const getConfig = async (baseUrl?: string): Promise<FrontendConfig | undefined> => {
if (isBuildTime) {
return undefined
}
const response = await new GetApiRequestBuilder<FrontendConfig>('config', baseUrl).sendRequest()
return response.asParsedJsonObject()
}

View file

@ -16,8 +16,8 @@ import type { Note, NoteDeletionOptions, NoteMetadata } from './types'
* @return Content and metadata of the specified note.
* @throws {Error} when the api request wasn't successful.
*/
export const getNote = async (noteIdOrAlias: string): Promise<Note> => {
const response = await new GetApiRequestBuilder<Note>('notes/' + noteIdOrAlias).sendRequest()
export const getNote = async (noteIdOrAlias: string, baseUrl?: string): Promise<Note> => {
const response = await new GetApiRequestBuilder<Note>('notes/' + noteIdOrAlias, baseUrl).sendRequest()
return response.asParsedJsonObject()
}