mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
add readme and comments about shared dir
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
### Shared directory
|
||||
|
||||
This directory contains code and types that is used by both frontend and backend. It is subject to some limitations. In files under this directory, you cannot:
|
||||
|
||||
- Use path aliases in imports: instead of `import ... from @/shared/...` use relative path `../types/`
|
||||
- Import files from elsewhere in frontend into this directory
|
||||
|
||||
This is because backend code does not have frontend's path aliases defined, and the code from backend does not get access to any other files in frontend than this directory.
|
||||
|
||||
Check [validator readme](./validators/README.md) in it's own directory.
|
||||
@@ -1,3 +1,5 @@
|
||||
/* For types that describe data */
|
||||
|
||||
import * as Prisma from '../../../../backend/prisma/generated/now_test_client/default'
|
||||
import * as LogPrisma from '../../../../backend/prisma/generated/now_log_test_client/default'
|
||||
import { Editable, FixBigInt, RowState } from './util'
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* Misc types that are more miscellaneous or general than data-folder */
|
||||
|
||||
export enum Role {
|
||||
Admin = 1,
|
||||
EditUnrestricted = 2,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* Util-types - generics or otherwise used for type-technical things */
|
||||
|
||||
/* This makes all fields optional, except for array-type fields.
|
||||
Also wraps the objects inside arrays as Editable, adding rowState-field in them.
|
||||
Applies itself recursively to all nested objects even inside arrays. */
|
||||
|
||||
@@ -33,10 +33,3 @@ To know if user is creating a new entry or editing existing one, check if the id
|
||||
At the moment you can only create validators for existing and defined fields of editData. This is limiting in some cases and creating validators that check multiple fields (as is necessary in references) requires some trickery. Similarly you cannot create multiple validators for the same field.
|
||||
|
||||
Validators are only run if the data is defined! If the value of a key of editData == undefined, the data is not checked even if it is set as required in the validator. Similarly if a key does not exist in editData, it will not be checked even if the data would be required. This is also the case in backend. This may lead to mistakes getting into the db if some data must be set but it is not defined at all.
|
||||
|
||||
The files in this folder, and also backendTypes.d.ts, cannot
|
||||
|
||||
- Use path aliases in imports
|
||||
- Import files from elsewhere in frontend
|
||||
|
||||
Because these files are used also by backend, and backend container only gets access to these files in frontend.
|
||||
|
||||
Reference in New Issue
Block a user