Skip to content

thjs-122: Setup project base starter #126

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

Merged
merged 19 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5706b79
thjs-122: * prepare packages/shared workspace
v0ldemar01 Jun 6, 2024
1046a47
thjs-122: * prepare packages/backend workspace
v0ldemar01 Jun 8, 2024
4e8985b
thjs-122: * prepare packages/frontend workspace
v0ldemar01 Jun 9, 2024
1b49833
thjs-122: * eslint configuration for packages/shared workspace
v0ldemar01 Jun 9, 2024
0e35917
thjs-122: * eslint configuration for apps/backend workspace
v0ldemar01 Jun 10, 2024
fb6f980
thjs-122: * eslint configuration for apps/frontend workspace
v0ldemar01 Jun 10, 2024
388f308
thjs-122: * prettier configuration for workspaces
v0ldemar01 Jun 10, 2024
c69e61d
thjs-122: * stylelint configuration for workspaces
v0ldemar01 Jun 10, 2024
3236ea6
thjs-122: * knip configuration for workspaces
v0ldemar01 Jun 10, 2024
e4f4ad5
thjs-122: * lint staged configuration for workspaces
v0ldemar01 Jun 10, 2024
a846666
thjs-122: * ls-lint configuration for workspaces
v0ldemar01 Jun 10, 2024
f1003bc
thjs-122: * fix vs-code eslint configuration for workspaces
v0ldemar01 Jun 10, 2024
1ea0300
thjs-122: * stylelint configuration for workspaces
v0ldemar01 Jun 10, 2024
9e2864a
thjs-122: - useless test config
v0ldemar01 Jun 10, 2024
4c40689
thjs-122: * application module structure changes
v0ldemar01 Jun 10, 2024
4e5bbe7
thjs-122: * fix ci lint trash
v0ldemar01 Jun 10, 2024
dcc3faa
thjs-122: * commitlint config
v0ldemar01 Jun 10, 2024
5d513fe
thjs-122: * fix ci linting commitlint config
v0ldemar01 Jun 10, 2024
2911b7e
thjs-122: * fix ci linting prettier config
v0ldemar01 Jun 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
149 changes: 0 additions & 149 deletions .eslintrc.yml

This file was deleted.

6 changes: 0 additions & 6 deletions .lintstagedrc.yml

This file was deleted.

14 changes: 6 additions & 8 deletions .ls-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ ls:
ignore:
- .git
- node_modules
- build
- shared/build
- shared/node_modules
- client/build
- client/node_modules
- server/build
- server/node_modules
- .idea
- packages/shared/build
- packages/shared/node_modules
- apps/frontend/build
- apps/frontend/node_modules
- apps/backend/build
- apps/backend/node_modules
13 changes: 0 additions & 13 deletions .prettierrc.yml

This file was deleted.

2 changes: 0 additions & 2 deletions .stylelintrc.yml

This file was deleted.

11 changes: 0 additions & 11 deletions server/.env.example → apps/backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,3 @@ DB_CLIENT=pg
DB_POOL_MIN=1
DB_POOL_MAX=10

#
# AUTHENTICATION
#
# SECRET_KEY has to be changed to own random secret key
SECRET_KEY=secretkeysecretkeysecretkey

# Image Storage
#
# GYAZO_ACCESS_TOKEN - has to be changed to a real key from Gyazo
GYAZO_UPLOAD_API_URL=https://upload.gyazo.com/api/upload
GYAZO_ACCESS_TOKEN=gyazoaccesstoken
54 changes: 54 additions & 0 deletions apps/backend/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import baseConfig from '../../eslint.config.js';

/** @typedef {import("eslint").Linter.FlatConfig} */
let FlatConfig;

/** @type {FlatConfig} */
const ignoresConfig = {
ignores: ['build']
};

/** @type {FlatConfig[]} */
const overridesConfigs = [
{
files: ['knexfile.ts'],
rules: {
'import/no-default-export': ['off']
}
},
{
files: ['jest.config.js'],
rules: {
'@typescript-eslint/explicit-function-return-type': ['off'],
'@typescript-eslint/no-magic-numbers': ['off'],
'@typescript-eslint/no-unsafe-argument': ['off'],
'@typescript-eslint/no-unsafe-assignment': ['off'],
'@typescript-eslint/no-unsafe-call': ['off'],
'@typescript-eslint/no-unsafe-member-access': ['off'],
'@typescript-eslint/no-unsafe-return': ['off'],
'import/no-default-export': ['off']
}
},
{
files: ['src/db/migrations/**/*.ts'],
rules: {
'unicorn/filename-case': [
'error',
{
case: 'snakeCase'
}
]
}
},
{
files: ['src/libs/modules/controller/controller.module.ts'],
rules: {
'@typescript-eslint/no-magic-numbers': ['off']
}
}
];

/** @type {FlatConfig[]} */
const config = [...baseConfig, ignoresConfig, ...overridesConfigs];

export default config;
11 changes: 5 additions & 6 deletions server/jest.config.js → apps/backend/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';

import { pathsToModuleNameMapper } from 'ts-jest';

import tsconfigJson from './tsconfig.json' assert { type: 'json' };
Expand All @@ -19,19 +18,19 @@ const manageMapper = mapper => ({
});

export default {
testEnvironment: 'jest-environment-node',
preset: 'ts-jest/presets/default-esm',
extensionsToTreatAsEsm: ['.ts'],
transformIgnorePatterns: ['node_modules/'],
testPathIgnorePatterns: ['node_modules/', 'dist/', 'build/'],
moduleNameMapper: manageMapper(
pathsToModuleNameMapper(tsconfigJson.compilerOptions.paths, {
prefix: sourcePath
})
),
preset: 'ts-jest/presets/default-esm',
testEnvironment: 'jest-environment-node',
testPathIgnorePatterns: ['node_modules/', 'dist/', 'build/'],
testTimeout: 10_000,
transform: {
'^.+\\.tsx?$': ['ts-jest', { useESM: true }]
},
testTimeout: 10_000,
transformIgnorePatterns: ['node_modules/'],
workerIdleMemoryLimit: '1GB'
};
3 changes: 3 additions & 0 deletions apps/backend/knexfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { database } from '~/libs/modules/database/database.js';

export default database.environmentsConfig;
12 changes: 12 additions & 0 deletions apps/backend/lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { default as baseConfig } from '../../lint-staged.config.js';

/** @type {import('lint-staged').Config} */
const config = {
...baseConfig,
'**/*.ts': [
() => 'npm run lint:js -w apps/backend',
() => 'npm run lint:type -w apps/backend'
]
};

export default config;
54 changes: 54 additions & 0 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "@thread-js/backend",
"private": true,
"engines": {
"node": "18.18.x",
"npm": "9.8.x"
},
"type": "module",
"scripts": {
"knex": "cross-env NODE_OPTIONS=\"--loader ts-paths-esm-loader\" knex",
"migrate:dev": "npm run knex migrate:latest",
"migrate:dev:make": "npm run knex migrate:make -- -x ts",
"migrate:dev:down": "npm run knex migrate:down",
"migrate:dev:rollback": "npm run knex migrate:rollback -- --all",
"migrate:dev:unlock": "npm run knex migrate:unlock",
"migrate:dev:reset": "npm run migrate:dev:rollback && npm run migrate:dev",
"seed:run": "npm run knex seed:run",
"start:dev": "nodemon --exec \"node --loader ts-paths-esm-loader\" ./src/main.ts",
"lint:type": "npx tsc --noEmit",
"lint:js": "npx eslint . --max-warnings=0",
"lint": "concurrently \"npm:lint:*\"",
"build": "tsc && tsc-alias",
"pretest": "cross-env NODE_ENV=test npm run migrate:dev",
"test": "cross-env NODE_ENV=test node --experimental-vm-modules --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js --config jest.config.js --runInBand --forceExit --detectOpenHandles",
"test:auth": "npm run test -- --verbose --rootDir=tests/modules/auth/"
},
"dependencies": {
"@fastify/static": "6.12.0",
"@thread-js/shared": "*",
"convict": "6.2.4",
"dotenv": "16.3.1",
"fastify": "4.25.1",
"knex": "3.1.0",
"objection": "3.1.3",
"pg": "8.7.3",
"pino": "9.1.0",
"qs": "6.11.2"
},
"devDependencies": {
"@faker-js/faker": "8.3.1",
"@jest/globals": "29.7.0",
"@types/convict": "6.1.6",
"@types/jest": "29.5.11",
"@types/pg": "8.10.9",
"@types/qs": "6.9.10",
"cross-env": "7.0.3",
"jest": "29.7.0",
"nodemon": "3.0.2",
"pino-pretty": "10.3.0",
"ts-jest": "29.1.1",
"ts-node": "10.9.2",
"ts-paths-esm-loader": "1.4.3"
}
}
Loading
Loading