Skip to content
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

Lf 4395 setup typescript on backend #3428

Open
wants to merge 22 commits into
base: integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d89353c
LF-4395 use @swc/jest for tests transformation
navDhammu Sep 10, 2024
1facaec
LF-4395 use node v20 in github actions
navDhammu Sep 10, 2024
9abc14a
LF-4395 create tsconfig and dev script with @swc-node
navDhammu Sep 11, 2024
b0f56e3
LF-4395 convert .knex to esm modules
navDhammu Sep 11, 2024
d28933b
LF-4395 add typescript and setup build scripts with tsc
navDhammu Sep 11, 2024
918b136
LF-4395 update dev and start scripts
navDhammu Sep 11, 2024
d8f5969
LF-4395 remove import.meta from knexfile and update knex version
navDhammu Sep 11, 2024
b0c302f
LF-4395 convert server.js to typescript
navDhammu Sep 11, 2024
114d2a5
LF-4395 update lint-staged with typechecking
navDhammu Sep 11, 2024
b799979
LF-4395 setup typescript-eslint and update eslint version
navDhammu Sep 11, 2024
e76b724
LF-4395 fix linting of json files
navDhammu Sep 11, 2024
d6ed249
LF-4395 require node >= 20.6 in package.json
navDhammu Sep 11, 2024
eec6db0
LF-4395 remove nodemon
navDhammu Sep 11, 2024
5f7a2da
LF-4395 update npm scripts containing nodemon
navDhammu Sep 11, 2024
58530b5
LF-4395 remove babel dependencies
navDhammu Sep 11, 2024
259183c
LF-4395 update .nvmrc to v20
navDhammu Sep 12, 2024
e139d47
LF-4395 modify root tsconfig to noEmit and include tests
navDhammu Sep 12, 2024
fbc570a
LF-4395 add separate tsconfig for src and adjust build script
navDhammu Sep 12, 2024
84f3923
LF-4395 use node v20 in api linting job
navDhammu Sep 12, 2024
690be55
LF-4395 add dotenv setupFile for jest tests
navDhammu Sep 29, 2024
43a0e2d
Merge branch integration into LF-4395-setup-typescript-on-backend
navDhammu Sep 29, 2024
4016d81
LF-4395 install jest types
navDhammu Sep 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/automated_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
api_unit_tests:
name: API Unit Tests
runs-on: ubuntu-20.04
container: node:18.16.1
container: node:20.17.0
services:
postgres:
image: postgres:13
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint_translation_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Install dependencies for Node.js server
run: npm install
Expand Down
2 changes: 0 additions & 2 deletions packages/api/.eslintignore

This file was deleted.

29 changes: 0 additions & 29 deletions packages/api/.eslintrc.cjs

This file was deleted.

3 changes: 2 additions & 1 deletion packages/api/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
src/jobs/locales/*/crop.json
src/jobs/locales/*/*_old.json
/exports/temp
**/logs
**/logs
dist
64 changes: 21 additions & 43 deletions packages/api/.knex/knexfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details, see <https://www.gnu.org/licenses/>.
*/
// import path from 'path';
// import { fileURLToPath } from 'url';

const dotenv = require('dotenv');
const path = require('path');
import dotenv from 'dotenv';
dotenv.config({ path: '../.env' });

dotenv.config({ path: path.resolve(__dirname, '../.env') });
const migrations = {
directory: '../db/migration',
};

const root = path.resolve(__dirname, '../');
const seeds = {
directory: '../db/seeds',
};

module.exports = {
export default {
development: {
client: 'postgresql',
connection: {
Expand All @@ -32,12 +34,8 @@ module.exports = {
password: process.env.DEV_DATABASE_PASSWORD,
port: process.env.DEV_DATABASE_PORT || 5432,
},
migrations: {
directory: root + '/db/migration',
},
seeds: {
directory: root + '/db/seeds',
},
migrations,
seeds,
},

ci: {
Expand All @@ -48,12 +46,8 @@ module.exports = {
user: 'postgres',
password: 'postgres',
},
migrations: {
directory: root + '/db/migration',
},
seeds: {
directory: root + '/db/seeds',
},
migrations,
seeds,
},

integration: {
Expand All @@ -66,24 +60,16 @@ module.exports = {
password: process.env.DEV_DATABASE_PASSWORD,
ssl: { rejectUnauthorized: false },
},
migrations: {
directory: root + '/db/migration',
},
seeds: {
directory: root + '/db/seeds',
},
migrations,
seeds,
},

production: {
client: 'postgresql',
debug: true,
connection: process.env.DATABASE_URL,
migrations: {
directory: root + '/db/migration',
},
seeds: {
directory: root + '/db/seeds',
},
migrations,
seeds,
ssl: {
rejectUnauthorized: false,
},
Expand All @@ -98,12 +84,8 @@ module.exports = {
port: process.env.TEST_DATABASE_PORT || 5432,
},
pool: { min: 0, max: 100 },
migrations: {
directory: root + '/db/migration',
},
seeds: {
directory: root + '/db/seeds',
},
migrations,
seeds,
},
pipeline: {
client: 'postgresql',
Expand All @@ -115,11 +97,7 @@ module.exports = {
password: 'pipeline',
},
pool: { min: 0, max: 100 },
migrations: {
directory: root + '/db/migration',
},
seeds: {
directory: root + '/db/seeds',
},
migrations,
seeds,
},
};
4 changes: 2 additions & 2 deletions packages/api/.knex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"version": "1.0.0",
"description": "",
"main": "knexfile.js",
"type": "commonjs",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
}
1 change: 1 addition & 0 deletions packages/api/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
2 changes: 1 addition & 1 deletion packages/api/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.16.1
20.17.0
16 changes: 0 additions & 16 deletions packages/api/babel.config.cjs

This file was deleted.

31 changes: 31 additions & 0 deletions packages/api/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import json from 'eslint-plugin-json';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
files: ['**/*.json'],
...json.configs['recommended'],
extends: [eslint.configs.recommended, ...tseslint.configs.recommended],
},
{
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
},
);
5 changes: 5 additions & 0 deletions packages/api/lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
'*.{ts}': [() => 'tsc'],
'*.{md,yml,json,js,ts}': 'prettier --write',
'*.{js,ts}': 'eslint --quiet --fix',
};
Loading
Loading