Skip to content

Commit

Permalink
Merge branch 'main' of github.com:codex-team/notes.api into fix/uploa…
Browse files Browse the repository at this point in the history
…d-router
  • Loading branch information
slaveeks committed Jun 29, 2024
2 parents 0a16346 + 9615a41 commit 4582d2a
Show file tree
Hide file tree
Showing 108 changed files with 1,513 additions and 919 deletions.
34 changes: 0 additions & 34 deletions .eslintrc.cjs

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ app-config.local.yaml
.idea
dist
database
s3

# Logs
logs
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20
v22.1.0
98 changes: 98 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import CodeX from 'eslint-config-codex';
import { plugin as TsPlugin, parser as TsParser } from 'typescript-eslint';
/**
* @todo connect architecture config
*/
export default [
...CodeX,
/**
* Override only for config files
*/
{
name: 'codex/codestyle/configs',
files: ['eslint.config.mjs', 'vitest.config.js'],
rules: {
'n/no-unpublished-import': ['off'],
'@typescript-eslint/naming-convention': ['off'],
},
},
/**
* Override for dev files that are not in source code (logically)
*/
{
name: 'codex/codestyle/dev-files',
files: ['src/tests/**/*', '**/*.test.ts'],
languageOptions: {
parser: TsParser,
parserOptions: {
project: 'tsconfig.test.json',
tsconfigRootDir: './',
sourceType: 'module',
},
},
rules: {
/**
* Current eslint version (9.2.0) has no alias resolver so this error is unfixable
*/
'n/no-missing-import': ['off'],
'n/no-unpublished-import': ['error', {
allowModules: ['vitest', 'postgres-migrations', '@testcontainers/localstack'],
ignoreTypeImport: true,
}],
/**
* @todo get rid of this rule ignores and solve all eslint errors occured
*/
'@typescript-eslint/no-unsafe-member-access': ['off'],
'@typescript-eslint/no-unsafe-call': ['off'],
'@typescript-eslint/no-unsafe-assignment': ['off'],
'@typescript-eslint/no-magic-numbers': ['off'],
'@typescript-eslint/no-unsafe-return': ['off'],
'@typescript-eslint/restrict-template-expressions': ['off'],
'jsdoc/require-jsdoc': ['off'],
},
},
/**
* Override for sourve code files
*/
{
name: 'notex.api',
ignores: ['vitest.config.js', 'eslint.config.mjs', 'src/tests/**/*', '**/*.test.ts'],
plugins: {
'@typescript-eslint': TsPlugin,
},
languageOptions: {
parser: TsParser,
parserOptions: {
project: 'tsconfig.eslint.json',
tsconfigRootDir: './',
sourceType: 'module',
},
},
rules: {
/**
* Current eslint version (9.2.0) has no alias resolver so this error is unfixable
*/
'n/no-missing-import': ['off'],
'n/no-unpublished-import': ['error'],
'n/no-unsupported-features/es-builtins': ['error', {
version: '>=22.1.0',
}],
'@typescript-eslint/naming-convention': ['error', {
selector: 'property',
format: ['camelCase', 'PascalCase'],

filter: {
regex: '^(?!(2xx|2[0-9][0-9]|application/json)$).*',
match: true,
},
}],
/**
* @todo get rid of this rule ignores and solve all eslint errors occured
*/
'@typescript-eslint/no-misused-promises': ['off'],
'jsdoc/require-jsdoc': ['off'],
'jsdoc/informative-docs': ['off'],
'jsdoc/require-returns-description': ['off'],
},
},
];
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"start": "node dist/index.js -c app-config.yaml -c app-config.local.yaml",
"start:dev": "yarn build && node dist/index.js -c app-config.yaml -c app-config.local.yaml",
"migrate": "node --loader ts-node/esm ./src/repository/storage/postgres/migrations/index.ts -c app-config.yaml -c app-config.local.yaml",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"lint": "eslint",
"lint:fix": "eslint --fix",
"test:dev": "vitest",
"test": "vitest run",
"coverage": "vitest run --coverage",
Expand All @@ -25,15 +25,17 @@
"@types/node": "^20.2.3",
"@types/pg": "^8.10.2",
"@vitest/coverage-v8": "^0.34.5",
"eslint": "^8.41.0",
"eslint-config-codex": "^1.9.2",
"eslint": "^9.2.0",
"eslint-config-codex": "^2.0.0",
"eslint-import-resolver-alias": "1.1.2",
"eslint-plugin-vitest": "^0.3.1",
"nodemon": "^2.0.22",
"pino-pretty": "^10.0.0",
"postgres-migrations": "^5.3.0",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6",
"typescript": "^5.0.4",
"typescript-eslint": "^7.6.0",
"vitest": "^1.4.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/entities/editorTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default interface EditorTool {
* Tool URL in content delivery network
*/
cdn?: string;
}
};
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/domain/entities/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export enum FileType {
/**
* File is a part of note
*/
NoteAttachment = 1,
NoteAttachment = 1
}

/**
Expand All @@ -36,7 +36,7 @@ export type TestFileLocation = Record<never, never>;
* File location, when it is a part of note
*/
export type NoteAttachmentFileLocation = {
noteId: NoteInternalId,
noteId: NoteInternalId;
};

/**
Expand All @@ -48,8 +48,8 @@ export type FileLocation = TestFileLocation | NoteAttachmentFileLocation;
* File location type, wich depends on file type
*/
export interface FileLocationByType {
[FileType.Test]: TestFileLocation,
[FileType.NoteAttachment]: NoteAttachmentFileLocation,
[FileType.Test]: TestFileLocation;
[FileType.NoteAttachment]: NoteAttachmentFileLocation;
}

/**
Expand Down
9 changes: 4 additions & 5 deletions src/domain/entities/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export type ToolUsedInNoteContent = {
/**
* Name of certain editor tool
*/
name: EditorTool['name'],
name: EditorTool['name'];

/**
* Id of certain editor tool (nanoid)
*/
id: EditorTool['id']
id: EditorTool['id'];
};

/**
Expand All @@ -48,8 +48,8 @@ export interface Note {
id: string;
type: string;
data: unknown;
tunes?: {[name: string]: unknown}
}>
tunes?: { [name: string]: unknown };
}>;
};

/**
Expand All @@ -73,7 +73,6 @@ export interface Note {
tools: ToolUsedInNoteContent[];
}


/**
* Part of note entity used to create new note
*/
Expand Down
2 changes: 0 additions & 2 deletions src/domain/entities/noteList.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Note } from '@domain/entities/note.js';
import type { NotePublic } from '@domain/entities/notePublic.js';


/**
* Note list entity.
* An object with the "items" property containing a list of all existing notes created by the user
Expand All @@ -17,4 +16,3 @@ export type NoteList = {
export type NoteListPublic = {
items: NotePublic[];
};

3 changes: 1 addition & 2 deletions src/domain/entities/notePublic.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Note } from '@domain/entities/note.js';

type NotePublicProperties = 'content' | 'createdAt' | 'updatedAt'| 'creatorId';
type NotePublicProperties = 'content' | 'createdAt' | 'updatedAt' | 'creatorId';

export interface NotePublic extends Pick<Note, NotePublicProperties> {
/**
Expand All @@ -11,7 +11,6 @@ export interface NotePublic extends Pick<Note, NotePublicProperties> {

/**
*Change Note to NotePublic
*
* @param note - Note data to compose a public note
*/
export function definePublicNote(note: Note): NotePublic {
Expand Down
4 changes: 1 addition & 3 deletions src/domain/entities/noteSettings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Team } from './team.js';


/**
* Invitation hash. It's used to invite users to team
*/
Expand Down Expand Up @@ -55,7 +54,6 @@ export interface NoteSettingsPublic extends Pick<NoteSettings, NoteSettingsPubli

/**
* Define note settings for public usage
*
* @param noteSettings - note settings data
*/
export function definePublicNoteSettings(noteSettings: NoteSettings): NoteSettingsPublic {
Expand All @@ -71,7 +69,7 @@ export function definePublicNoteSettings(noteSettings: NoteSettings): NoteSettin
/**
* Notes settings creation attributes, omitting id, because it's generated by database, omitting cover, because it should be generated after insertion of the note
*/
type NoteSettingsCreationAttributes = Omit<NoteSettings, 'id' |'cover'>;
type NoteSettingsCreationAttributes = Omit<NoteSettings, 'id' | 'cover'>;

export type {
NoteSettingsCreationAttributes
Expand Down
10 changes: 5 additions & 5 deletions src/domain/entities/noteVisit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ export default interface NoteVisit {
/**
* Unique property identifier
*/
id: number,
id: number;

/**
* Internal id of the note
*/
noteId: NoteInternalId,
noteId: NoteInternalId;

/**
* Id of the user
*/
userId: User['id'],
userId: User['id'];

/**
* Time when note was visited for the last time (timestamp with timezone)
*/
visitedAt: string,
}
visitedAt: string;
}
2 changes: 1 addition & 1 deletion src/domain/entities/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export enum MemberRole {
/**
* Team member can read and write notes
*/
Write = 1,
Write = 1
}

/**
Expand Down
15 changes: 7 additions & 8 deletions src/domain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,37 @@ export interface DomainServices {
/**
* Note service instance
*/
noteService: NoteService,
noteService: NoteService;

/**
* Note settings service instance
*/
noteSettingsService: NoteSettingsService,
noteSettingsService: NoteSettingsService;

/**
* Auth service instance
*/
authService: AuthService,
authService: AuthService;

/**
* User service instance
*/
userService: UserService,
userService: UserService;

/**
* AI service instance
*/
aiService: AIService
aiService: AIService;

/**
* Editor tools service instance
*/
editorToolsService: EditorToolsService,
editorToolsService: EditorToolsService;

/**
* File uploader service instance
*/
fileUploaderService: FileUploaderService,
fileUploaderService: FileUploaderService;

/**
* Note visits service instance
Expand All @@ -56,7 +56,6 @@ export interface DomainServices {

/**
* Initiate services
*
* @param repositories - repositories
* @param appConfig - app config
*/
Expand Down
Loading

0 comments on commit 4582d2a

Please sign in to comment.