Front-end shared library for interacting with the projects-backend. This library centralizes API calls, data models, utility interfaces, and permission logic common to multiple applications.
shared-project-frontend/
├── apis/ # All backend API calls (TypeScript)
│ └── configureAPI # Header and global config setup (via ofetch)
├── models/ # Data models corresponding to the backend
├── interfaces/ # Utility interfaces shared throughout the application
└── lib/ # Shared libraries (e.g., permission management)
└── permissions.ts # Access checks (modify/delete objects, organizations, etc.)
npm install shared-project-frontend
# or
yarn add shared-project-frontendConfigure the ofetch instance before any usage:
import { configureOptionsAPI, configureClientAPI } from '@shared-projects-frontend/apis';
// optional, custom ofetch instance
const myofetch = ofetch.create(...)
configureClientAPI(myofetch)
// a callback called before each request
configureOptionsAPI(() => ({
baseURL: 'my-base-url',
headers: {
'my default-header': 'my-default-value'
}
}));import { getProjects, getUser, getOrganization, ... } from '@shared-projects-frontend/apis';
const projects = await getProjects();import type { Project, Organization, ... } from '@shared-projects-frontend/models';
const project: Project = /* ... */;import type { PaginatedResult, Query, .... } from '@shared-projects-frontend/interfaces';import { getAllProjects } from '@shared-projects-frontend/apis';
import { canEditProject, canDeleteOrganization, userRights } from '@shared-projects-frontend/lib';
const user = getUser()
const projects = getAllProjects()
const organization = getOrganization("LPI")
const rights = userRights(user)
projects.forEach((project) => {
if (canEditProject(rights, organization.id, project)) {
// Allowed
}
})This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

